Opposite of array_intersect?

前端 未结 5 1096
盖世英雄少女心
盖世英雄少女心 2021-02-06 20:36

Is there a built-in function to get all members of array 1 which do not exist in array 2?
I know how to do it programatically, only wondering if there is a built-in function

5条回答
  •  离开以前
    2021-02-06 21:13

    Just to clarify as I was looking into this question the answers of @Jon and @Dallas Caley are both correct depending on the domain of your arrays.

    If the array against what you are comparing is the full domain of your results then a simple array_diff will suffice as per @Jon answer.

    If the array against what you are comparing is NOT the full domain of your results then you should go with the double array_diff as per @Dallas Caley answer.

提交回复
热议问题