note 14014 added to function.array-filter.php
| From: | fgilles at php2 dot chek dot com | Date: | Fri, 13 Jul 2001 15:03:26 +0000 |
| Subject: | note 14014 added to function.array-filter.php | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-15325@lists.php.net to get a copy of this message | ||
dub4u, your function doesn't truly replace array_filter() because it doesn't restore
originals $array keys.
Here is a replacement for array_filter() for PHP4 < 4.0.6:
function array_filter_it($array, $callback)
{
$farray = array ();
while(list($key,$val) = each($array))
if ($callback($val))
$farray[$key] = $val;
return $farray;
}
http://www.php.net/manual/en/function.array-filter.php