How to reset indexes in array_diff result?

前端 未结 2 778
后悔当初
后悔当初 2021-01-07 16:27

I have two arrays: Array ( [0] => 2 [1] => 3 ) and Array ( [0] => 2 ).

I want to get the value, which is not in second array. So I

相关标签:
2条回答
  • 2021-01-07 17:05

    you can use array_values(array_diff($arr1, $arr2)); if order doesn't matter

    0 讨论(0)
  • 2021-01-07 17:16

    You should run array_values() on the result and this would give you a new array with indexes starting at 0.

    This is a known shortcoming of array_diff(), check the php docs.

    0 讨论(0)
提交回复
热议问题