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.
Click the PHP Examples link to view other examples created with PHP.
So let us know how this function is used. PHP
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); ?> |