note 39309 deleted from function.trim by tomsommer
| From: | tomsommer@php.net | Date: | Fri, 23 Jan 2004 23:37:29 +0000 |
| Subject: | note 39309 deleted from function.trim by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-64090@lists.php.net to get a copy of this message | ||
Note Submitter: mike-php@emerge2.com
----
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 );