note 87460 deleted from function.trim by mazzanet
| From: | mazzanet@php.net | Date: | Thu, 20 Aug 2009 14:24:56 +0000 |
| Subject: | note 87460 deleted from function.trim by mazzanet | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-159701@lists.php.net to get a copy of this message | ||
Note Submitter: mcblack
----
@Brizz
you can easily create a function to trim arrays... this works fine for me.
<?php
function trim_array( $array, $charset = 0 ) {
foreach ( $array as $str ) {
if( $charset !== 0 ) {
$out[] = trim( $str, $charset );
} else {
$out[] = trim( $str );
}
}
return $out;
}
$array = array( "foo\n\n", "\nfoo\n", "\tfoo" );
$trimmed = trim_array( $array );
print_r( $trimmed );
print "\n";
$array = array( "0bar0", "#bar#", "~bar~" );
$trimmed = trim_array( $array, "0#~" );
print_r( $trimmed );
?>