我有一个多维数组,可以根据用户输入增加。我想在数组内部做 array_intersect 以获得键之间的公共值。
像例子
Array ( [php] => Array ( [0] => 36 [1] => 51 [2] => 116 [3] => 171 [4] => 215 [5] => 219 [6] => 229 [7] => 247 [8] => 316 ) [java] => Array ( [0] => 14 [1] => 16 [2] => 19 [3] => 24 [4] => 25 [5] => 26 [6] => 29 [7] => 31 [8] => 33 [9] => 34 [10] => 35 [11] => 36 [12] => 37 [13] => 40 [14] => 45 [15] => 49 [16] => 51 ) )
预期输出应该是(36,51)
这是我能得到的
通过这个,
$intersected_array = call_user_func_array('array_intersect', $array);
但是如果我的数组还有第三个键,它在所有三个中都没有共同的值
喜欢
Array ( [php] => Array ( [0] => 36 [1] => 51 [2] => 116 [3] => 171 [4] => 215 [5] => 219 [6] => 229 [7] => 247 [8] => 316 ) [java] => Array ( [0] => 14 [1] => 16 [2] => 19 [3] => 24 [4] => 25 [5] => 26 [6] => 29 [7] => 31 [8] => 33 [9] => 34 [10] => 35 [11] => 36 [12] => 37 [13] => 40 [14] => 45 [15] => 49 [16] => 51 ) [ajax] => Array ( [0] => 91 [1] => 110 [2] => 113 [3] => 172 ) )
然后它把我的输出作为键具有最大值的结果。在这种情况下,它将返回我所有的java
键值。
但我的预期输出是0
。请帮忙。