PHP merge arrays with only NOT DUPLICATED values

前端 未结 5 1955
青春惊慌失措
青春惊慌失措 2020-11-29 06:03

I need to merge two arrays into 1 array but what I need is to remove before the main data they b oth have in common (duplicated values i mean), I need only unique values whe

5条回答
  •  我在风中等你
    2020-11-29 07:04

    A little bit late answer, but I just found that the array union operator + does the job quite greatly (found here at the 3rd section).

    $array1 + $array2 = $array //if duplicate found, the value in $array1 will be considered ($array2 value for array_merge, if keys clearly specified)
    

提交回复
热议问题