Generate a 6 Digit Unique Number using PHP
mt_rand(100000,999999); This is the inbuild function of a php, you can generate a random number of 6 digit through it. So let us know how this function is used.
Click the PHP Examples link to view other examples created with PHP.
PHP Code 1: How to Generate 6 Digit Unique Random Numbers in PHP
1 2 3 4 5 6 | <?php $randomid = mt_rand(100000,999999); echo $randomid; ?> |
PHP Code 2: Generate 6 digit random number
1 2 3 4 5 6 | <?php $randomid = random_int(100000,999999); echo $randomid; ?> |
PHP Code 3: Best way to generate 6 digit random number
1 2 3 4 5 6 7 8 9 | <?php function generateRandomNumber($digit){ return substr(str_shuffle('0123456789'),0,$digit); } generateRandomNumber(6); ?> |
Generate a 6 Digit Unique Number using PHP, Generate a 8 Digits Random Number using PHP, PHP rand() Function, Using the PHP Rand() Functions, Get 8 Digits Random Number in PHP, Create six Digits Random Number Using PHP, six Digit Unique Number Generate in PHP
mt_rand(10000000,99999999); This is the inbuild function of a php, you can generate a random number of 8 digit through it.
So let us know how this function is used.
PHP Code 1: How to Generate 8 Digit Unique Random Numbers in PHP
1 2 3 4 5 6 | <?php $randomid = mt_rand(10000000,99999999); echo $randomid; ?> |
PHP Code 2: Generate 8 digit random number
1 2 3 4 5 6 | <?php $randomid = random_int(10000000,99999999); echo $randomid; ?> |
PHP Code 3: Best way to generate 8 digit random number
1 2 3 4 5 6 7 8 9 | <?php function generateRandomNumber($digit){ return substr(str_shuffle(str_repeat($x='0123456789',$digit)),0,$digit); } echo generateRandomNumber(8); ?> |