数组A、B、C、D
里面的个数count不一定都相同。
组合顺序是固定的 A[rand] + B[rand] + C[rand] + D[rand] = 不重复字符串
怎么获取最大的组合数量、不重复字符串??
回复讨论(解决方案)
本帖最后由 xuzuning 于 2013-10-11 23:59:51 编辑
数量 = 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');print_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
[10] => a1b2c3d1
[11] => a2b2c3d1
[12] => a1b1c1d2
[13] => a2b1c1d2
[14] => a1b2c1d2
[15] => a2b2c1d2
[16] => a1b1c2d2
[17] => a2b1c2d2
[18] => a1b2c2d2
[19] => a2b2c2d2
[20] => a1b1c3d2
[21] => a2b1c3d2
[22] => a1b2c3d2
[23] => a2b2c3d2
[24] => a1b1c1d3
[25] => a2b1c1d3
[26] => a1b2c1d3
[27] => a2b2c1d3
[28] => a1b1c2d3
[29] => a2b1c2d3
[30] => a1b2c2d3
[31] => a2b2c2d3
[32] => a1b1c3d3
[33] => a2b1c3d3
[34] => a1b2c3d3
[35] => a2b2c3d3
)
好代码.解决了.谢谢
Stellungnahme:Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn