我想知道如何对对象数组进行 array_intersect。
最佳答案
您可以将 array_uintersect 与 spl_object_hash 结合使用,请参见示例:
array_uintersect($a, $b, function($a, $b) {
return strcmp(spl_object_hash($a), spl_object_hash($b));
});
其中 '$a' 和 '$b' 是您想要相交的一些对象的数组。
关于php - 对象数组 php 的数组相交,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2834607/