多维数组差分 php
2022-08-31 00:13:33
我有两个多维数组,我想要差异。例如。我在下面采用了二维二维数组
$array1 = Array (
[a1] => Array (
[a_name] => aaaaa
[a_value] => aaa
)
[b1] => Array (
[b_name] => bbbbb
[b_value] => bbb
)
[c1] => Array (
[c_name] => ccccc
[c_value] => ccc
)
)
$array2 = Array (
[b1] => Array (
[b_name]=> zzzzz
)
)
现在我想要这两个数组的关键区别。我尝试过array_diff_key(),但它不适用于多维。
array_diff_key($array1, $array2)
我想要如下输出
//output
$array1 = Array (
[a1] => Array (
[a_name] => aaaaa
[a_value] => aaa
)
[b1] => Array (
[b_value] => bbb
)
[c1] => Array (
[c_name] => ccccc
[c_value] => ccc
)
)
如果您认为我的问题是真实的,请接受并回答。谢谢。
编辑
现在,如果第二个数组是
$array2 = Array( [b1] => zzzzz)
结果应该是
$array1 = Array (
[a1] => Array (
[a_name] => aaaaa
[a_value] => aaa
)
[c1] => Array (
[c_name] => ccccc
[c_value] => ccc
)
)