note 16630 deleted from function.array-filter by jimw
| From: | jimw@php.net | Date: | Thu, 08 Nov 2001 00:04:56 +0000 |
| Subject: | note 16630 deleted from function.array-filter by jimw | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-20572@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;
}