Voting

: min(four, seven)?
(Example: nine)

The Note You're Voting On

dml at nm dot ru
13 years ago
The built-in function returns wrong result when input arrays have duplicate values.
Here is a code that works correctly:

<?php
function array_intersect_fixed($array1, $array2) {
$result = array();
foreach (
$array1 as $val) {
if ((
$key = array_search($val, $array2, TRUE))!==false) {
$result[] = $val;
unset(
$array2[$key]);
}
}
return
$result;
}
?>

<< Back to user notes page

To Top