PHP 4 >= 4.3.0, PHP 5, PHP 7, PHP 8
array_diff_assoc - Computes the difference of arrays with additional index check

array_diff_assoc( array$array, ... array$arrays ): array

Compares array against arrays and returns the difference. Unlike array_diff the array keys are also used in the comparison.



The array to compare from


Arrays to compare against

Return Values

Returns an array containing all the values from array that are not present in any of the other arrays.



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]);.


Ensure you pass arguments in the correct order when comparing similar arrays with more keys. The new array should be the first in the list.

Related Functions

Example of array_diff_assoc

Show all examples for array_diff_assoc

PHP Version:

Function array_diff_assoc:

Arrays Functions

Most used PHP functions