【问题标题】:How can I compute the intersection of an unknown number of arrays in php?如何计算 php 中未知数量数组的交集?
【发布时间】:2011-12-17 06:41:04
【问题描述】:

我有一个数组数组,我想找到包含数组的交集。

我的问题是 array_intersect 函数需要在参数中明确指定数组。我无法用我的数组数组来提供函数。

我能做什么?

Array
(
    [0] => Array
        (
            [0] => 1
            [1] => 1504
            [2] => 2181
            [3] => 488
            [4] => 554
            [5] => 1539
            [6] => 494
            [7] => 2022
        )

    [1] => Array
        (
            [0] => 51
            [1] => 617
            [2] => 651
            [3] => 788
            [4] => 799
            [5] => 835
            [6] => 863
            [7] => 407
            [8] => 650
            [9] => 783
        )

)

【问题讨论】:

    标签: php arrays multidimensional-array array-intersect


    【解决方案1】:

    试试call_user_func_array

    call_user_func_array('array_intersect', $your_array_here);
    
    猜你喜欢
    • 2011-07-20
    • 1970-01-01
    • 1970-01-01
    • 2010-12-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多