How would i use array_intersect() with the arrays in an array?

ぃ、小莉子 提交于 2020-01-25 22:43:47

问题


I have a dynamic amount of arrays in a specific array.
Let's call this specific array: FatherArray

This FatherArray has a dynamic amount of arrays in it, right now for example: Child1Array,Child2Array. Next time it gets called it could have more or less than those 2 Child(number)Arrays.

So I want to use the function array_intersect() with the arrays (children) of FatherArray as parameters, so like array_intersect(Child1Array,Child2Array).
I don't have a clue how i could do this dynamically, neither could I find anything about it, any help would greatly be appreciated


回答1:


If your version is reasonably new (v5.6):

array_intersect(...$FatherArray);

Otherwise:

call_user_func_array('array_intersect', $FatherArray);

Demo: see comment by Mark (thx @MarkBaker)



来源:https://stackoverflow.com/questions/47201552/how-would-i-use-array-intersect-with-the-arrays-in-an-array

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