In the following PHP program:
<?php
$array1=['a'=>'brown','b'=>'green','c'=>'yellow','d'=>'blue','e'=>'magenta'];
$array2=['f'=>'black','g'=>'white','b'=>'violet','c'=>'pink'];
function my_function($k1,$k2){
if($k1===$k2)
return 0;
return($k1>$k2)?1:-1;
}
$result=array_intersect_ukey($array1,$array2,'my_function');
print_r($result);
?>
Output:
Array ( [b] => green [c] => yellow )
Question 1:
I believe that return 0 means false, and returning anything other than 0 is true. So, basically this program returns false when keys match and true when keys don't match. But it should exactly be the opposite. Why is this?
Question 2:
Comparing whether two keys are equal is all right. But how can we find the greater one and lesser one between two keys in string format. Is the ASCII value is being checked for?