PHP array_diff_assoc() Function

PHP array_diff_assoc Function


Description :

The array_diff_assoc() function compares the elements of two or more arrays and returns the differences. Unlike array_diff(), the array keys are also used in the comparison.

Syntax

The basic syntax of the array_diff_assoc() function is given with:

array_diff_assoc(array1, array2,array3 ...);

 

Parameter Values : 
Parameter Description
array1 Required. The array to compare from
array2 Required. An array to compare against
array3,... Optional. More arrays to compare against

 

Example1 :Compare the keys and values of two arrays, and return the differences:

Output :

Array
(
    [a] => apple
    [b] => banana
)

 

Example2 : Compare the keys and values of four arrays, and return the differences:

Output :

Array
(
    [b] => banana
    [d] => date
)