To return the unique elements (those with a key that exists only once in either array but not in both) try:
function array_unique_diff ($array1, $array2)
{
array_merge(array_diff_key($array1, $array2), array_diff_key($array2, $array1));
}
Example:
$array1 = array('blue' => 1, 'red' => 2, 'green' => 3, 'purple' => 4);
$array2 = array('green' => 5, 'blue' => 6, 'yellow' => 7, 'cyan' => 8);
array_diff_key($array1, $array2)
returns
array ( 'red' => 2, 'purple' => 4 )
array_diff_key($array2, $array1)
returns
array ( 'yellow' => 7, 'cyan' => 8, )
array_unique_diff($array1, $array2);
returns
array ( 'red' => 2, 'purple' => 4, 'yellow' => 7, 'cyan' => 8, )