note 15566 added to function.array-filter
| From: | rucci at wpi dot nospam dot edu | Date: | Tue, 18 Sep 2001 02:04:15 +0000 |
| Subject: | note 15566 added to function.array-filter | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-18104@lists.php.net to get a copy of this message | ||
if you want to filter and lose key information (condense the length of the array)
then use
function array_filter_it($array, $callback)
{
$farray = array ();
while(list($key,$val) = each($array))
if ($callback($val))
$farray[] = $val;
return $farray;
}
That is the same as the previous users Note except The $key is removed so that PHP picks the next
number in the array instead of its original key
http://www.php.net/manual/en/function.array-filter.php