时间:2021-07-01 10:21:17 帮助过:8人阅读
set_time_limit(0);
$test = M('test');
$_run = true;
$_order_id = rand(0, 100000);
while ($_run) {
$orderInfo = $test->where("val = ".$_order_id)->find();
if(empty($orderInfo)){
$_run = false;
return $_order_id;
}else{
$_order_id = rand(0, 100000);
}
}
$m = 100000;
$c = 101;
$b = 81;
$n = 0;
for($i=0; $i<100000; $i++) {
$n = ($n * $c + $b) % $m;
$r[] = $n;
}
print_r(array_count_values(array_count_values($r)));
Array可知 $r 中保有 0 - 99999 随机排列的数字,且每个数字只会出现一次
(
[1] => 100000
)