二维数组取交集

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
c<?php
$array_a = [
[
"id" => 14
],
[
"id" => 15
]
];
$array_b = [
[
"id" => 14
],
[
"id" => 16
]
];
$result = array_uintersect_uassoc($array_a, $array_b, function($value_a, $value_b) {
if ($value_a['id']===$value_b['id']) {
return 0;
}
return 1;
}, function($key_a, $key_b) {
return 0;
});
print_r($result);