I have two arrays, and I am using array_diff_assoc() to get the difference, but it always returns the common set row in the result
It should be returning the new q sets row. What’s wrong with my approach?
Sample data:
$array1 = [
[12 => 'new q sets'],
[11 => 'common set']
]
$array2 => [
[11 => 'common set']
];
After calling array_diff_assoc($array1, $array2), my output is:
[
[11 => 'common set']
]
http://php.net/manual/en/function.array-diff-assoc.php
The
(string)value of any array is"Array". Thus, your call toarray_diff_associs effectively comparing these two things:Since the thing that is different between those two is the
[1]key/value pair from the first array, you get that back ([1] => Array( [11] => common set )).