array_diff_assoc ( ) – Find unique key value pairs when comparing arrays

The “array_diff_assoc” php array  function is used to compute the difference of arrays Keys and Values and will return an array that contains only the differences between exact key and value pairs of arrays.

Syntax:

array_diff_assoc($targetArray, $array2, $array3, $array4, etc...)

Example:

<?php
$array1 = array("strong"=>"John", "sexy" => "Betty", "pretty" => "Susan");
$array2 = array( "strong" => "John", "pretty" => "Susan");
$newArray = array_diff_assoc($targetArray, $array2);

foreach ($newArray as $key => $value) {
        echo "$key - $value 
"; 
}
?>

Output:

sexy - Betty