array_intersect a variable amount of arrays

▼魔方 西西 提交于 2019-12-01 07:49:04

First of all, turn those arrays into an array of arrays. Then you can use array_reduce combined with array_intersect to reduce a variable amount of arrays down to one.

snovikov

Try this:

$fullArray = array($array1, $array2, $array3...);
call_user_func_array('array_intersect', $fullArray);
Lyle Malik

You can turn those array to a single array named $total_array by using array_combine(), then use array_intersect($full_array, $total_array). I hope this useful

One can use:

$intersect = array_intersect(...$fullArray);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!