Arrays A, B, C, D
The number count is not necessarily the same.
The combination order is fixed A[rand] + B[rand] + C[rand] + D[rand] = Do not repeat the string
How do I get the maximum number of combinations, not repeating strings??
Reply to discussion (solution)
This post was last edited by xuzuning on 2013-10-11 23:59:51
Quantity = Count (A) * COUNT (B) * COUNT (C) * COUNT (D)
$a = Array (' A1 ', ' A2 '); $b = Array (' B1 ', ' B2 '); $c = Array (' C1 ', ' C2 ', ' C3 '); $d = Array (' D1 ', ' D2 ', ' D3 ');p Rint_r (func ($a, $ B, $c, $d)); function func () { $d = Func_get_args (); $r = Array_shift ($d); while ($d) { $t = array (); foreach (Array_shift ($d) as $x) foreach ($r as $y) $t [] = $y. $x; $r = $t; } return $r;}
Array
(
[0] = A1b1c1d1
[1] = A2b1c1d1
[2] = A1B2C1D1
[3] = A2b2c1d1
[4] = A1b1c2d1
[5] = A2b1c2d1
[6] = A1b2c2d1
[7] = A2b2c2d1
[8] = A1b1c3d1
[9] = A2b1c3d1
[Ten] = A1b2c3d1
[One] = A2b2c3d1
[[] = A1b1c1d2
[+] = a2b1c1d2
[+] = a1b2c1d2
[[] = A2b2c1d2
[+] = A1B1C2D2
[+] = A2B1C2D2
[+] = A1B2C2D2
[+] = A2B2C2D2
[+] = a1b1c3d2
[+] = a2b1c3d2
[] = A1b2c3d2
[All] = A2b2c3d2
[] = A1b1c1d3
[+] = A2b1c1d3
[+] = A1b2c1d3
[+] = A2b2c1d3
[+] = a1b1c2d3
[+] = a2b1c2d3
[+] = a1b2c2d3
[+] = a2b2c2d3
[+] = A1b1c3d3
[+] = A2b1c3d3
[+] = A1b2c3d3
[+] = A2b2c3d3
)
Good code. Solved. Thank you.