PHP Manual: array_diff_assoc
array_diff_assoc
(PHP 4 >= 4.3.0, PHP 5)
array_diff_assoc -- Computes the difference of arrays with additional index checkDescription
array array_diff_assoc ( array array1, array array2 [, array ...] )
Compares array1 against array2 and
returns the difference. Unlike array_diff() the array
keys are used in the comparision.
Parameters
array1The array to compare from
array2An array to compare against
...More arrays to compare against
Return Values
Returns an array containing all the values from
array1 that are not present in any of the other arrays.
Examples
Example 2. array_diff_assoc() example Two values from key => value pairs are considered equal only if (string) $elem1 === (string) $elem2 . In other words a strict check takes place so the string representations must be the same.
The above example will output:
|
Notes
Note: This function only checks one dimension of a n-dimensional array. Of course you can check deeper dimensions by using, for example, array_diff_assoc($array1[0], $array2[0]);.