Compare the keys of two arrays with user-defined key comparison function, return differences in PHP
Description
The following code shows how to compare the keys of two arrays with user-defined key comparison function, return differences.
Example
/*w w w. j a v a 2s . com*/
<?php
function myfunction($a,$b){
if ($a===$b){
return 0;
}
return ($a>$b)?1:-1;
}
$a1=array("a"=>"red","b"=>"green","c"=>"blue");
$a2=array("a"=>"blue","b"=>"black","e"=>"ELang");
$result=array_diff_ukey($a1,$a2,"myfunction");
print_r($result);
?>
The code above generates the following result.