Recently came across function array_uintersect. Just wondering if any one can explain how input params are passed as I got the unexpected inputs passed to callback function, I have already went through This answer but couldn't find answer to my question. Any help or leads will be appreciated, Just trying to understand working of call back function.
NOTE: RESULT OF FUNCTION IS PERFECTLY FINE.
Code:
function myfunction($a,$b) {
echo "$a -- $b \n";
if ($a===$b) {
return 0;
}
return ($a>$b)?1:-1;
}
$a1 = array(1,2,3);
$a2 = array(4,5,1);
$result = array_uintersect($a1,$a2,"myfunction");
print_r($result);
As we are passing both the arrays as parameters,expected the inputs to be values from each array where as got below result.
Result:
1 -- 2
2 -- 3
4 -- 5
5 -- 1
4 -- 1
1 -- 1
1 -- 2
2 -- 4
3 -- 4
Array ( [0] => 1 )