The array_uintersect_assoc() function compares array keys, and compares array values in a user-made function, and returns an array.
Syntax
array_uintersect_assoc(arr1, arr2, arr3, … , compare_func)
Parameters
arr1 − The first array to compare from.
arr2 − The second array to be compared with.
arr3 − More arrays to compare.
compare_func − The comparison function. It must return an integer less than, equal to, or greater than zero if the first argument is considered to be respectively less than, equal to, or greater than the second.
Return
The array_uintersect_assoc() function returns an array containing all the values of the first array that are not present in any of the other parameters.
Example
The following is an example −
<?php function compare_func($a, $b) { if ($a === $b) { return 0; } return ($a > $b)? 1:-1; } $arr1 = array("p"=>"one","q"=>"two","r"=>"three"); $arr2 = array("p"=>"five","q"=>"four","r"=>"three"); $res = array_uintersect_assoc($arr1, $arr2, "compare_func"); print_r($res); ?>
Output
Array ( [r] => three )