随机产生独一无二6位的数字和对应的12位数字.比如:需要1万个
如:
244855 587753043808
558676 168139952943
------解决方案--------------------
把随机出来的数据记录下来,下次随机的时候比对,暂时只想到这么一个方法,不过很麻烦,晓得有其他方法不....
------解决方案--------------------
For($i=10000;$i<=99999;$i++) {
Echo "244855 5877530{$i}<br>";
}
------解决方案--------------------
你可以这样生成
- PHP code
for($i=0; $i<30000; $i++) { //产生3万个6位数 $r[] = rand(100000, 999999);}if(count(array_flip(array_count_values($r)))>1) {//检查是否有重复 exit('有重复, 重新执行');}foreach(array_chunk($r, 3) as $t) { //切割成3个一组 $res[] = array( $t[0], $t[1].$t[2]); //放到数组, 你根据你的需要进行保存}print_r($res);
------解决方案--------------------
------解决方案--------------------
- PHP code
<?php$numbers = range(100000,999999);srand((float)microtime()*1000000);shuffle($numbers);$i = 10000;foreach ($numbers as $number) { if ($i-- < 0) break; echo "$number\r\n";}?>