Php Arrays Key & Values Comparison
What is array_diff_assoc Function?
Explanation
The "array_diff_assoc" function is used to compute the difference of arrays Keys and Values and return the difference of arrays.
Syntax:
array_diff_assoc(array1,array2,array3,....)
In the above syntax "array1" is the array to be compare with, "array2" is the array which is to be compared to, atleast two arrays should be there,"array 3" is optional.It returns all values of "array1" that is not present in any other array.
Example :
<?php
$a = array( 'x' => 'x','y' => 'y','g' => 'g');
$b = array( 'x' => 'x','y' => 'y',);
print_r(array_diff_assoc($a,$b));
?>
Result :
Array ([g] => g)
In the above example the two arrays "$a","$b" are compared, by default all values of the first array are taken, 'g' is the only value that is not in the array "$b", so its displayed as output.