array_diff_assoc()
As array_diff() is to array_intersect(), this function is to array_intersect_assoc().
It gives you an array with values found in the first array and not in any of the other arrays you’re comparing but also looks at the keys. So if the keys aren’t the same, it will appear in the result.
$arr1 = array('a' => 'apple', 'b' => 'banana', 'c' => 'carrot'); $arr2 = array('a' => 'apple', 'd' => 'carrot', 'b' => 'banana'); $arr3 = array('a' => 'apple', 'b' => 'appleton', 'c' => 'banana', 'd' => 'Bananaman'); $new = array_diff_assoc($arr1, $arr2); var_export($new); /* array ( 'c' => 'carrot' ) */ $new = array_diff_assoc($arr1, $arr3); var_export($new); /* array ( 'b' => 'banana', 'c' => 'carrot' ) */ $new = array_diff_assoc($arr1, $arr2, $arr3); var_export($new); /* array ( 'c' => 'carrot' ) */
See the manual entry for array_diff_assoc()
