5组数字,每组取一个组成不相同的5位数,大神
程序员文章站
2022-05-31 16:03:29
...
例 : 012345678,013456789,023456789,012456789,023456789
这5组数每组取一个组成不相同的5位数
这5组数每组取一个组成不相同的5位数
回复讨论(解决方案)
$d = explode(',', '012345678,013456789,023456789,012456789,023456789');$r = array();for($i=0; $i你可能需要有随机性的 $d = explode(',', '012345678,013456789,023456789,012456789,023456789');$r = array();for($i=0; $i我是想把所有能组成的5位数都显示出来,我没写清楚
循环 去重呗
$d = array_map('str_split', explode(',', '012345678,013456789,023456789,012456789,023456789'));print_r(foo($d));function foo($d) { $r = array_pop($d); while($d) { $t = array(); foreach(array_pop($d) as $k1=>$x) { foreach($r as $k2=>$y) $t[] = "$x $y"; } $r = $t; } return $r;}