An algorithm accepted by array_intersect()friends should first assume that all values of the first array are present in other arrays; during the iteration, it will remove elements that do not support this statement.
If an element is not found in one of the other arrays, the implementation can do two things:
PHP . , , , , . :
$a = ['a.a0', 'a.a1', 'b.a2', 'c.a3'];
$b = ['a.c0', 'd.c1'];
function cmp_val($a, $b)
{
echo "$a <=> $b\n";
return strcmp($a[0], $b[0]);
}
print_r(array_uintersect($a, $b, 'cmp_val'));
:
...
-- intersect starts
a.a0 <=> a.c0
a.a0 <=> a.a1 <-- match
a.a1 <=> b.a2
b.a2 <=> d.c1 <-- no match
c.a3 <=> d.c1
, , , diff; , .