How to generate unique random numbers in PHP?
How to Generate Unique Random Numbers in PHP?
mt_rand();
This is the inbuild function of a php,The mt_rand() function generates a random integer using the Mersenne Twister
algorithm. You can generate a random numbers through it.
Syntax
mt_rand();
or
mt_rand(min,max);
Example : Generating 6 digit random numbers using mt_rand() function.
<?php
$random_no = mt_rand(100000,999999);
echo $random_no;
?>
- Happy Coding
Comments
Post a Comment