I want to generate a 6 digit random number using the PHP mt_rand()
function.
I know the PHP mt_rand()
function only takes 2 parameters: a <
If the first member nunmber can be zero, then you need format it to fill it with zeroes, if necessary.
<?php
$number = mt_rand(10000,999999);
printf("[%06s]\n",$number); // zero-padding works on strings too
?>
Or, if it can be form zero, you can do that, to:
<?php
$number = mt_rand(0,999999);
printf("[%06s]\n",$number); // zero-padding works on strings too
?>