从动态生成的数组计算可能的组合

时间:2016-09-07 13:18:53

标签: php arrays combinations

我的动态生成很少。 s可以是2,3,4,5或更多。是否可以计算数组值的组合,其中第一个数组值始终是组合的第一个值。

[attributes_id_1] = 
(
    [0] =  5

)
    [attributes_id_2] = 
(
    [0] = 8
    [1] = 9
    [2] = 10
)
    [attributes_id_3] = 
(
    [0] = 12
    [1] = 15
)

由于:
5,8,12
5,9,12
5,10,12
5,8,15
5,9,15
5,10,15

[attributes_id_1] => 
    (
        [0] => 5
        [1] => 6
    )

[attributes_id_2] => 
    (
        [0] => 8
        [1] => 9
    )

[attributes_id_3] => 
    (
        [0] => 12
        [1] => 13
    )

[attributes_id_4] => 
    (
        [0] => 14
        [1] => 15
    )

由于:
5,8,12,14
5,8,12,15
5,8,13,14-
5,8,13,15
5,9,12,14
.....
6,8,12,14
6,8,12,15
6,8,13,14
6,8,13,15
6,9,12,14
.....

[attributes_id_1] => 
    (
        [0] => 5
        [1] => 6
    )

[attributes_id_2] => 
    (
        [0] => 8
        [1] => 9
        [2] => 10
    )

由于:
5,8
5,9
5,10
6,8
6,9
6,10

0 个答案:

没有答案