note 68013 deleted from function.trim by hholzgra
| From: | hholzgra@php.net | Date: | Thu, 02 Aug 2012 12:24:16 +0000 |
| Subject: | note 68013 deleted from function.trim by hholzgra | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-189647@lists.php.net to get a copy of this message | ||
Note Submitter: phazei at excite dot com
----
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:
<?php
function trim_array($totrim) {
if (is_array($totrim)) {
$totrim = array_map("trim_array", $totrim);
} else {
$totrim = trim($totrim);
}
return $totrim;
}
?>
USE:
<?php
$trimmed_array = trim_array($untrimmed_array);
?>
This function should recurse all embeded arrays.