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

Popular posts from this blog

Validation Code For Phone Number Using preg_match() in Php

Writing data to a file using Python

Simple HTML Form Elements For Registration Page Example