Javatpoint Logo
Javatpoint Logo

PHP array_diff_assoc() function

The array_diff_assoc() function is used to compare an array against another array and returns the difference. In other words, we can say that array_diff_assoc() function compares the keys and values of two or more arrays and return an array that contains the entries from array1 that are not present in array2 or array3. This function was introduced in PHP 4.3.


Parameter Description Is compulsory
array1 The array to compare form compulsory
array2 An array to compare against compulsory
array3 More arrays to compare against optional

Return Type

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

Example 1


Array ( [2] => green [3] => blue  [4] => black  )

Example 2


Array (  [b] => mango  )

Example 3


Array ( [a] => orange [b] => mango [c] => banana )

Example 4


Array(  [3]=> Array ( [4] => black ) )

Help Others, Please Share

facebook twitter pinterest