我如何将array_intersect()与数组中的数组一起使用? [英] How would i use array_intersect() with the arrays in an array?

查看:142
本文介绍了我如何将array_intersect()与数组中的数组一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个特定的数组中有动态数量的数组.
我们将其称为特定数组: FatherArray

FatherArray 中具有动态数量的数组,例如,现在为: Child1Array Child2Array .下次调用它时,它的个数可能会多于或少于这两个Child(number)Arrays.

因此,我想将array_intersect()函数与 FatherArray 的数组(子级)作为参数一起使用,就像array_intersect(Child1Array,Child2Array)一样.
我不知道如何动态地执行此操作,也找不到任何有关它的帮助,将不胜感激

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

推荐答案

如果您的版本相当新(

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

array_intersect(...$FatherArray);

否则:

call_user_func_array('array_intersect', $FatherArray);

演示:请参阅Mark(thx @MarkBaker)发表的评论

Demo: see comment by Mark (thx @MarkBaker)

这篇关于我如何将array_intersect()与数组中的数组一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆