继承人我的代码
while($x <= $num) {
$code = rand(1,666666).rand(2,88888888);
$INC = qry_run("Insert into ms_code2 (code) Values(".$code.")");
$x++;
}
Run Code Online (Sandbox Code Playgroud)
主要问题是当这个循环工作时,它有时会产生 14 个数字,有时是 10,有时是 12
我不会讨论我们究竟能得到多少“随机”,我很确定这会产生一个足够随机的数字!:)
function randomNumber($length) {
$result = '';
for($i = 0; $i < $length; $i++) {
$result .= mt_rand(0, 9);
}
return $result;
}
Run Code Online (Sandbox Code Playgroud)
..当然,那只是 echo randomNumber(14);