我如何将array_intersect()与数组中的数组一起使用?

我如何将array_intersect()与数组中的数组一起使用?

问题描述:

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

我在特定数组中有一个动态数量的数组。
让我们调用这个特定的数组: FatherArray strong>

这个 FatherArray strong>中有一个动态数量的数组,例如: 的 Child1Array 强>, Child2Array strong>即可。 下次调用时它可能比那些2个子(数字)数组更多或更少。

我想使用函数array_intersect()和 FatherArray strong>作为参数,所以像array_intersect(Child1Array,Child2Array)。
我不知道我怎么能动态地做到这一点,我也找不到任何关于它的东西,任何帮助都会很大 不胜感激 p> div>

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)