I have two multidimensional arrays. I want to check each item in array 1 and see if it's in array 2 and vice versa.
For example:
$arr1 = [
[
id => '1',
order => '123238'
],
[
id => '2',
order => '33278'
],
[
id => '3',
order => '8892372'
]
];
$arr2 = [
[
id => '1',
order => '349483'
],
[
id => '2',
order => '9837283'
],
[
id => '3',
order => '33278'
]
];
I want to check by order.
So something like this:
if($arr1['order'] does not exist in $arr2['order']) {
echo 'abc';
}
if($arr2['order'] does not exist in $arr1['order']) {
echo 'xyz';
}
I've thought about doing foreach loop for both but it won't let me know arr # it's missing from.
How can I achieve this?
array_diffto compute the difference between both.in_arraywork if the id is different?idandorderwhere you define the array.