note 68013 added to function.trim
| From: | phazei at excite dot com | Date: | Mon, 10 Jul 2006 11:39:59 +0000 |
| Subject: | note 68013 added to function.trim | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-114630@lists.php.net to get a copy of this message | ||
I had some issues using <? array_map('trim',$array) ?> when there was an array in
array. All arrays were replaced by the string "Array", drove me crazy.
Hopefully this will help someone:
<?
function trim_array($totrim) {
if (is_array($totrim)) {
$totrim = array_map("trim_array", $totrim);
} else {
$totrim = trim($totrim);
}
return $totrim;
}
?>
USE:
<?
$trimmed_array = trim_array($untrimmed_array);
?>
This function should recurse all embeded arrays.
----
Server IP: 64.71.164.2
Probable Submitter: 68.104.18.88
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.trim.php
Edit -- http://master.php.net/note/edit/68013
Del: integrated -- http://master.php.net/note/delete/68013/integrated
Del: useless -- http://master.php.net/note/delete/68013/useless
Del: bad code -- http://master.php.net/note/delete/68013/bad+code
Del: spam -- http://master.php.net/note/delete/68013/spam
Del: non-english -- http://master.php.net/note/delete/68013/non-english
Del: in docs -- http://master.php.net/note/delete/68013/in+docs
Del: other reasons-- http://master.php.net/note/delete/68013
Reject -- http://master.php.net/note/reject/68013
Search -- http://master.php.net/manage/user-notes.php