我有一个数组数组,在运行脚本时可能有不同的元素数。 p>
$ strict = [
[0] => ['one','two','three','four'],
[1] => ['one','two','four','eight'],
[2] => ['two','four','ten','twenty'],
/ * [x] => [ 。 。] * /
];
$ result = array_intersect($ strict [0],$ strict [1],$ strict [2]);
print_r($ result); //显示['two','four'];
code> pre>
我想做类似这样的事情: p>
$ result = array_intersect($ strict);
code> pre>
我传入一个动态长度的数组数组,而 array_intersect code>将会去 通过每一个,只采取共同的条目。 p>
执行 array_intersect($ strict) code>不起作用,因为该函数至少需要两个参数。 p>
可能像 p>
array_intersect(function($ array){
$ list ='';
foreach($ array) 如$ el){
$ list。= $ el。',';
}
$ list = rtrim($ list,',');
返回eval($ list); \ n});
code> pre>
虽然这个特殊的方法仍然会抛出错误 p>
警告:array_intersect() :至少需要2个参数,1
给出 p>
blockquote>
div>