array intersect for object array php

前端 未结 8 1489
独厮守ぢ
独厮守ぢ 2021-01-04 05:55

I want to know how to array_intersect for object array.

8条回答
  •  离开以前
    2021-01-04 06:08

    The correct way to check whether two objects are equal is to use ==. Therefore:

    array_uintersect($arr1, $arr2, function ($a1, $a2) { return $a1 == $a2; });
    

提交回复
热议问题