note 46531 deleted from function.trim by sean
| From: | sean@php.net | Date: | Thu, 14 Oct 2004 14:04:21 +0000 |
| Subject: | note 46531 deleted from function.trim by sean | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-78538@lists.php.net to get a copy of this message | ||
Note Submitter: rubbish at garbage dot com
----
It's not, the forach way is about 4.5 times faster than your other method. Use this code to
compare :
<?
for( $i=0; $i<10000; $i++ ) {
$db[$i] = " dskjdskjdlskjdlskjldskdjslkjd ";
}
echo microtime()."\n";
array_walk($db ,create_function('&$arr','$arr=trim($arr);'));
echo microtime()."\n\n\n";
for( $i=0; $i<10000; $i++ ) {
$db[$i] = " dskjdskjdlskjdlskjldskdjslkjd ";
}
echo microtime()."\n";
foreach ($db as $key=>$value) { $db[$key]=trim($value); }
echo microtime()."\n";
?>
----
Reason: useless example