note 39309 added to function.trim
| From: | mike-php at emerge2 dot com | Date: | Fri, 23 Jan 2004 22:11:07 +0000 |
| Subject: | note 39309 added to function.trim | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-64088@lists.php.net to get a copy of this message | ||
This is the function I use to trim all the elements of an array, even a multi-dimensional array:
function trim_array( $given ) {
return is_array( $given ) ? array_map( 'trim_array', $given ) : trim( $given );
}
The function returns an array if passed an array, a string if passed a string, so it is always safe
to use.
It is called in a similar manner to the built-in trim() function:
$trimmed_array = trim_array( $untrimmed_array );
----
Manual Page -- http://www.php.net/manual/en/function.trim.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+39309
Delete -- http://master.php.net/manage/user-notes.php?action=delete+39309&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+39309&report=yes
Search -- http://master.php.net/manage/user-notes.php