note 42581 deleted from ref.array by aidan
| From: | aidan@php.net | Date: | Sun, 09 Oct 2005 09:14:57 +0000 |
| Subject: | note 42581 deleted from ref.array by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-96739@lists.php.net to get a copy of this message | ||
Note Submitter: Minots Estichá <minots at d0x dot de>
----
Sometimes it´s usefull to trim all values from a given array.
I wrote this function ( array_trim ) to do it for me:
<?php
function array_trim(&$arr)
{
while (list($key,$val)=each($arr)):
if ( (strtoupper($key) != $key or ''.intval($key) == "$key") && $key
!= "argc" and $key != "argv"):
if (is_string($val)):
$arr[$key] = trim($val);
endif;
if (is_array($val)):
$arr[$key] = array_trim($val);
endif;
endif;
endwhile;
return $arr;
}
?>
If there is a better way, feel free to send me a note via
feedback-formular at http://www.d0x.de/pages/kontakt.php .