array_compare
Bi-directional comparison of multi-dimensional arrays.
Summary
- array_compare Crawl through each array to find differences.
array_compare
function array_compare($array1, $array2)
Crawl through each array to find differences. This includes differences in type (i.e. “2”, 2 and 2.0 differ) as well as bits present on one side but not on the other. To catch differences, including those of type, you need to use var_dump() on the result; print_r() is too limited.
Discussed at length in the user contributed notes at http://ca.php.net/manual/en/function.array-diff-assoc.php
This version includes dwraven's replacement of isset() with array_key_exists(), as well as a new improvement to allow the comparison of non-array arguments.
Returns
An array with two elements, one containing what's in your first array, but not your second, and the second is vice versa.
License
This comes from a group discusson and effort on user notes on php.net. I don't think I can force GPL v3 on this unilaterally. Therefore, all I can say is use/modify this as you'd like, and if you distribute modified versions, please keep the mention that our effort on php.net got us this far. :-)