array difference

前端 未结 3 1390
闹比i
闹比i 2021-01-24 21:19

I need to get the difference between these two arrays, I\'ve tried array_diff($array1,$array2) without success, any idea?

array1

Array
(
            


        
3条回答
  •  庸人自扰
    2021-01-24 22:02

    According to array_diff,

    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]);.

    Therefore you cannot diff the second dimension of these arrays directly.

    Instead, maybe you can extract the status values with array_map, save as two 1-dimensional arrays, and then array_diff. If you have multiple keys, use a for loop.

提交回复
热议问题