PHP provides a function - rand() to generate the numbers randomly from one number to another number (ex:- 0 to 90).
rand() function has two parameters. The first parameter is for min number & the second is for max number. You get a random number from min to max in PHP. Separate parameter by comma ( , ).
rand() function example:-
<?php
$random_number = rand(0,90);
echo $random_number;
?>
Generate 5 digits random number - Simply pass min and max value in 5 digits in the first parameter.
<?php
$random_number = rand(10000,99999);
echo $random_number;
?>
Publish A Comment