Two sets of two-dimensional arrays, how to quickly find the elements of the travel set

$arr1 = [
    ["number" => "1001", "empno" => "9991","title"=>""],
    ["number" => "1001", "empno" => "9992","title"=>""],
    ["number" => "1002", "empno" => "9991","title"=>""],
    ["number" => "1002", "empno" => "9992","title"=>""],
    ["number" => "1001", "empno" => "9990","title"=>""]
];
$arr2 = [
    ["number" => "1001", "empno" => "9991","title"=>""],
    ["number" => "1001", "empno" => "9992","title"=>""],
    ["number" => "1002", "empno" => "9991","title"=>""],
    ["number" => "1002", "empno" => "9992","title"=>""]
];

if you have the above two arrays, just like the unique key value, number and empno cannot have the same array that is a repeat. The above $arr1 , and the last element is a difference element ( ["number" = >" 1001arrays, "empno" = >" 9990 calendar title = > Finance] ), which is a different element. Could you tell me how to find out quickly besides applying two foreach?

Php
Dec.18,2021

$arr3 = array_filter($arr1, function ($v) use ($arr2) {
  return !in_array($v, $arr2);
});
The simplest way to write

is
, but there is a flaw in this way. You can only find items in $arr1 that do not contain $arr2 . To find out two array difference sets, you need to encapsulate

again.
Menu