I have two arrays
Array1:
Array ( [0] => Array ( [0] => 3 [1] => 1 [2] => 4 ) [1] => Array ( [0] => 1 [1] => 6 ) )
Array2:
Array ( [0] => 1 [1] => 3 [2] => 2 )
I used array_diff
for comparing and getting the dif开发者_运维百科ference values, but the same key is coming ie.,
array_diff(Array1,Array2)
returns Array([0] =>3 [2] => 4)
but is there any other way to get difference and having result like
Array([0] =>3 [1] => 4)..
Assuming you've got array_diff working on the multidimensional array somehow, but from the docs:
This function only checks one dimension of a n-dimensional array. Of course you can check deeper dimensions by using array_diff($array1[0], $array2[0]);.
Use array_values around it.
array_values(array_diff($array1, $array2));
精彩评论