Compare values of three arrays with user function to compare values, and return matches in PHP
Description
The following code shows how to compare values of three arrays with user function to compare values, and return matches.
Example
/*from w w w . ja v a 2 s. c om*/
<?php
function myfunction($a,$b){
if ($a===$b){
return 0;
}
return ($a>$b)?1:-1;
}
$a1=array("a"=>"red","b"=>"Green","c"=>"blue","yellow");
$a2=array("A"=>"red","b"=>"GREEN","yellow","black");
$a3=array("a"=>"green","b"=>"red","yellow","black");
$result=array_uintersect($a1,$a2,$a3,"myfunction");
print_r($result);
?>
The code above generates the following result.