Voting

: two plus two?
(Example: nine)

The Note You're Voting On

Michael Richey
11 years ago
If you're looking for a true array_diff_assoc, comparing arrays to determine the difference between two, finding missing values from both, you can use this along with array_merge.

$a = array('a'=>1,'b'=>2,'c'=>3);
$b = array('a'=>1,'b'=>2,'d'=>4);
print_r(array_diff_assoc($a,$b));
// returns:
array
(
[c] => 3
)

print_r(array_diff_assoc($b,$a));
// returns
array
(
[d] => 4
)

print_r(array_merge(array_diff_assoc($a,$b),array_diff_assoc($b,$a)));
// returns
array
(
[c] => 3
[d] => 4
)

<< Back to user notes page

To Top