note 68013 modified in function.trim by felipe

From: Date: Wed, 06 Aug 2008 22:07:38 +0000
Subject: note 68013 modified in function.trim by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-143251@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: <?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. --was-- 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. http://php.net/manual/en/function.trim.php

« previous php.notes (#143251) next »