note 16630 added to function.array-filter
| From: | webmaster at phpnet dot be | Date: | Wed, 07 Nov 2001 13:19:17 +0000 |
| Subject: | note 16630 added to function.array-filter | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-20544@lists.php.net to get a copy of this message | ||
Hi there,
I have writen a function that allows you to filter the elements of an array. Just by compairing arr1
with arr2.
Example:
/*
farray (array input, array filter input)
Description:
The farray() function which is available from PHP 4.0
and higher compairs two Arrays. The second Array contains
the values that has to be filtered from the first Array.
*/
function farray($tmparr, $tokens){
for($t=0; $t<count($tokens); $t++){
$y=0;
for($i=0; $i<count($tmparr); $i++){
if(strcmp($tmparr[$i], $tokens[$t])){
$result_arr[$y++] = $tmparr[$i];
}
}
unset($result_arr[$y]);
for($x=0; $x<count($result_arr); $x++){
$tmparr = $result_arr[$x];
}
$tmparr = $result_arr;
$new_array = explode(" ", trim(implode(" ", $tmparr)));
}
return $new_array;
}
--
http://www.php.net/manual/en/function.array-filter.php
http://master.php.net/manage/user-notes.php?action=edit+16630
http://master.php.net/manage/user-notes.php?action=delete+16630
http://master.php.net/manage/user-notes.php?action=reject+16630