我有两个关联数组,如下所示
Array
(
[0] => Array
(
[description] => aaaaaa
[value] => 11111
[id] => 14
)
[1] => Array
(
[description] => dddddd
[value] => 44444
[id] => 0
)
)
Array
(
[0] => Array
(
[id] => 14
[value] => 11111
[description] => aaaaaa
)
[1] => Array
(
[id] => 15
[value] => 222222
[description] => bbbbbb
)
[2] => Array
(
[id] => 16
[value] => 333333
[description] => cccccc
)
)
我得到的结果是
Array
(
[0] => Array
(
[description] => aaaaaa
[value] => 11111
[id] => 14
)
[1] => Array
(
[description] => dddddd
[value] => 44444
[id] => 0
)
)
注意dddd
在第一个数组中可用,但在第二个数组中不可用。
我正在使用array_intersect_assoc( $array1, $array2 )
功能。
请帮忙。返回这样的结果是不合逻辑的
答案 0 :(得分:0)
使用以下代码
$intersect = array_uintersect($arr1, $arr2, 'compareDeepValue');
print_r($intersect);
function compareDeepValue($val1, $val2)
{
return strcmp($val1['value'], $val2['value']);
}
答案 1 :(得分:0)