I have two multidimensional arrays and I want the difference. For eg. I have taken two-dimensional two arrays below
$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
)
)
Now I want the key difference of these two arrays. I have tried array_diff_key() but it doesnot work for multidimensional.
array_diff_key($array1, $array2)
I want the output as following
//output
$array1 = Array (
[a1] => Array (
[a_name] => aaaaa
[a_value] => aaa
)
[b1] => Array (
[b_value] => bbb
)
[c1] => Array (
[c_name] => ccccc
[c_value] => ccc
)
)
If you think my question is genuine please accept it and answer. Thank you.
EDIT
Now if the second array is
$array2 = Array( [b1] => zzzzz)
The result should be
$array1 = Array (
[a1] => Array (
[a_name] => aaaaa
[a_value] => aaa
)
[c1] => Array (
[c_name] => ccccc
[c_value] => ccc
)
)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…