Q:

If array exists in array - multidimensional associative array

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?

A:

You can approach like this by using array_column and array_intersect_key
 $arr1 = array_column($arr1, null , 'order');
 $arr2 = array_column($arr2, null , 'order');
 print_r(array_intersect_key($arr1,$arr2));

Example :- https://3v4l.org/Imbao

