note 11392 deleted from function.array-intersect by irc-html
| From: | irc-html@php.net | Date: | Sat, 19 Jan 2002 21:02:47 +0000 |
| Subject: | note 11392 deleted from function.array-intersect by irc-html | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-25460@lists.php.net to get a copy of this message | ||
Here is the equivalent to array_intersect for PHP3 users :
function array_intersect($array1, $array2) {
if (sizeof($array1) > sizeof($array2)) {
$array3 = $array2;
$array2 = $array1;
$array1 = $array3;
}
$endarray = array (0 => 0);
$j = 0;
for ($i = 0; $i < sizeof($array1); $i++) {
if (in_array($array1[$i], $array2)){
$endarray[$j] = $array1 [$i];
$j++;
}
}
return ($endarray);
}