$array1 = array('rough', 'smooth', 'coarse');
$array2 = array('shiny', 'matte', 'rough');
$array3 = array('very large', 'large', 'medium', 'small');
$array=array_merge($array1,$array2,$array3);
$combinations=array();
for($x=0;$x<(count($array)-2);$x++) {
$a=$array[$x];
for ($y=$x+1;$y<count($array);$y++) {
$b=$array[$y];
for ($z=$y+1;$z<count($array);$z++) {
$c=$array[$z];
$combinations[]="$a, $b, $c";
}
}
}
这会输出所有值的所有可能组合,而不会重复任何内容。如下所示:
Array
(
[0] => rough, smooth, coarse
[1] => rough, smooth, shiny
[2] => rough, smooth, matte
[3] => rough, smooth, rough
[4] => rough, smooth, very large
[5] => rough, smooth, large
[6] => rough, smooth, medium
[7] => rough, smooth, small
[8] => rough, coarse, shiny
[9] => rough, coarse, matte
[10] => rough, coarse, rough
[11] => rough, coarse, very large
[12] => rough, coarse, large
[13] => rough, coarse, medium
[14] => rough, coarse, small
[15] => rough, shiny, matte
[16] => rough, shiny, rough
[17] => rough, shiny, very large
[18] => rough, shiny, large
[19] => rough, shiny, medium
[20] => rough, shiny, small
[21] => rough, matte, rough
[22] => rough, matte, very large
[23] => rough, matte, large
[24] => rough, matte, medium
[25] => rough, matte, small
[26] => rough, rough, very large
[27] => rough, rough, large
[28] => rough, rough, medium
[29] => rough, rough, small
[30] => rough, very large, large
[31] => rough, very large, medium
[32] => rough, very large, small
[33] => rough, large, medium
[34] => rough, large, small
[35] => rough, medium, small
[36] => smooth, coarse, shiny
[37] => smooth, coarse, matte
[38] => smooth, coarse, rough
[39] => smooth, coarse, very large
[40] => smooth, coarse, large
[41] => smooth, coarse, medium
[42] => smooth, coarse, small
[43] => smooth, shiny, matte
[44] => smooth, shiny, rough
[45] => smooth, shiny, very large
[46] => smooth, shiny, large
[47] => smooth, shiny, medium
[48] => smooth, shiny, small
[49] => smooth, matte, rough
[50] => smooth, matte, very large
[51] => smooth, matte, large
[52] => smooth, matte, medium
[53] => smooth, matte, small
[54] => smooth, rough, very large
[55] => smooth, rough, large
[56] => smooth, rough, medium
[57] => smooth, rough, small
[58] => smooth, very large, large
[59] => smooth, very large, medium
[60] => smooth, very large, small
[61] => smooth, large, medium
[62] => smooth, large, small
[63] => smooth, medium, small
[64] => coarse, shiny, matte
[65] => coarse, shiny, rough
[66] => coarse, shiny, very large
[67] => coarse, shiny, large
[68] => coarse, shiny, medium
[69] => coarse, shiny, small
[70] => coarse, matte, rough
[71] => coarse, matte, very large
[72] => coarse, matte, large
[73] => coarse, matte, medium
[74] => coarse, matte, small
[75] => coarse, rough, very large
[76] => coarse, rough, large
[77] => coarse, rough, medium
[78] => coarse, rough, small
[79] => coarse, very large, large
[80] => coarse, very large, medium
[81] => coarse, very large, small
[82] => coarse, large, medium
[83] => coarse, large, small
[84] => coarse, medium, small
[85] => shiny, matte, rough
[86] => shiny, matte, very large
[87] => shiny, matte, large
[88] => shiny, matte, medium
[89] => shiny, matte, small
[90] => shiny, rough, very large
[91] => shiny, rough, large
[92] => shiny, rough, medium
[93] => shiny, rough, small
[94] => shiny, very large, large
[95] => shiny, very large, medium
[96] => shiny, very large, small
[97] => shiny, large, medium
[98] => shiny, large, small
[99] => shiny, medium, small
[100] => matte, rough, very large
[101] => matte, rough, large
[102] => matte, rough, medium
[103] => matte, rough, small
[104] => matte, very large, large
[105] => matte, very large, medium
[106] => matte, very large, small
[107] => matte, large, medium
[108] => matte, large, small
[109] => matte, medium, small
[110] => rough, very large, large
[111] => rough, very large, medium
[112] => rough, very large, small
[113] => rough, large, medium
[114] => rough, large, small
[115] => rough, medium, small
[116] => very large, large, medium
[117] => very large, large, small
[118] => very large, medium, small
[119] => large, medium, small
)