Source Code:
(back to article)
<?php function compare_data($a, $b) { if ($a === $b) { return 0; } return ($a > $b) ? 1 : -1; } function compare_keys($a, $b) { if ($a === $b) { return 0; } return ($a > $b) ? 1 : -1; } $array1 = array("a" => "green", "b" => "brown", "c" => "blue", "d" => "red"); $array2 = array("a" => "green", "b" => "yellow", "blue", "d" => "red"); $result = array_uintersect_uassoc($array1, $array2, "compare_data", "compare_keys"); print_r($result); ?>
Result:
Report an issue