PHP有助于创建可能的组合

I have 3 arrays each containing some elements. I want to output each combination of its element with every element of other array.

e.g

array 1 = {'1.5mm', '2.5mm', '3.5mm', '4.5mm','5.5mm','6.5mm','7.5mm'}
array 2 = {'G/H', 'E/F', 'BLACK'}
array 3 = {'SI', 'VS-SI', 'SI-I', 'I/PK'}

The output would be
1.5mm   G/H  SI
1.5mm   G/H  VS-SI
1.5mm   G/H  SI-I
1.5mm   G/H  I/PK

1.5mm   E/F  SI
1.5mm   E/F  VS-SI
1.5mm   E/F  SI-I
1.5mm   E/F  I/PK

1.5mm   BLACK  SI
1.5mm   BLACK  VS-SI
1.5mm   BLACK  SI-I
1.5mm   BLACK  I/PK

Then this whole scenerio goes for '2.5mm', '3.5mm', '4.5mm',
'5.5mm','6.5mm' and '7.5mm' (each element of first array)

this way it will generate total 84 combinations

I am not sure to call it combination or permutation as these are different. Combinations of these will be in millions but according to my needs it should generate 84 possible outputs rather than generating each possible combination

thanks in advance

I think this does what you are attempting to achive, nested loops

define('BR','<br />' );

$array_1 = array('1.5mm', '2.5mm', '3.5mm', '4.5mm','5.5mm','6.5mm','7.5mm');
$array_2 = array('G/H', 'E/F', 'BLACK');
$array_3 = array('SI', 'VS-SI', 'SI-I', 'I/PK');

foreach( $array_1 as $size ){
    foreach( $array_2 as $code ){
        foreach( $array_3 as $val ){
            echo $size.' '.$code.' '.$val.BR;   
        }
    }
}

output:
1.5mm G/H SI
1.5mm G/H VS-SI
1.5mm G/H SI-I
1.5mm G/H I/PK
1.5mm E/F SI
1.5mm E/F VS-SI
1.5mm E/F SI-I
1.5mm E/F I/PK
1.5mm BLACK SI
1.5mm BLACK VS-SI
1.5mm BLACK SI-I
1.5mm BLACK I/PK
2.5mm G/H SI
2.5mm G/H VS-SI
2.5mm G/H SI-I
2.5mm G/H I/PK
2.5mm E/F SI
2.5mm E/F VS-SI
2.5mm E/F SI-I
2.5mm E/F I/PK
2.5mm BLACK SI
2.5mm BLACK VS-SI
2.5mm BLACK SI-I
2.5mm BLACK I/PK
3.5mm G/H SI
3.5mm G/H VS-SI
3.5mm G/H SI-I
3.5mm G/H I/PK
3.5mm E/F SI
3.5mm E/F VS-SI
3.5mm E/F SI-I
3.5mm E/F I/PK
3.5mm BLACK SI
3.5mm BLACK VS-SI
3.5mm BLACK SI-I
3.5mm BLACK I/PK
4.5mm G/H SI
4.5mm G/H VS-SI
4.5mm G/H SI-I
4.5mm G/H I/PK
4.5mm E/F SI
4.5mm E/F VS-SI
4.5mm E/F SI-I
4.5mm E/F I/PK
4.5mm BLACK SI
4.5mm BLACK VS-SI
4.5mm BLACK SI-I
4.5mm BLACK I/PK
5.5mm G/H SI
5.5mm G/H VS-SI
5.5mm G/H SI-I
5.5mm G/H I/PK
5.5mm E/F SI
5.5mm E/F VS-SI
5.5mm E/F SI-I
5.5mm E/F I/PK
5.5mm BLACK SI
5.5mm BLACK VS-SI
5.5mm BLACK SI-I
5.5mm BLACK I/PK
6.5mm G/H SI
6.5mm G/H VS-SI
6.5mm G/H SI-I
6.5mm G/H I/PK
6.5mm E/F SI
6.5mm E/F VS-SI
6.5mm E/F SI-I
6.5mm E/F I/PK
6.5mm BLACK SI
6.5mm BLACK VS-SI
6.5mm BLACK SI-I
6.5mm BLACK I/PK
7.5mm G/H SI
7.5mm G/H VS-SI
7.5mm G/H SI-I
7.5mm G/H I/PK
7.5mm E/F SI
7.5mm E/F VS-SI
7.5mm E/F SI-I
7.5mm E/F I/PK
7.5mm BLACK SI
7.5mm BLACK VS-SI
7.5mm BLACK SI-I
7.5mm BLACK I/PK