How to Generate 8 Digit Random Number Using PHP?

Hello Friends Today you will be told through this tutorial how you can generate random unique number of 8 digit by php. You will be told 2 method to generate random number of 8 digit by php.

Generate a 8 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 8 Digits Random Number Using PHP, 8 Digit Unique Number Generate in PHP

1st Method :- You can generate a random number by creating a function in php and running a loop in this function.

function generateCode($limit){
$code = '';
for($i = 0; $i < $limit; $i++) { $code .= mt_rand(0, 9); }
return $code;
echo generateCode(8);

2nd Method :- Through the second method you can create random number php only through mt_rand function.

$randomid = mt_rand(10000000,99999999); 
echo $randomid;