PHP mt_rand() - Math Functions

What is mt_rand Function?

Explanation

The "mt_rand()" function returns a random value between the range using the Mersenne Twister algorithm.

Syntax:


mt_rand(min,max)

In the above syntax "min", "max" values specifies the lowest and highest range from which the random value to be returned.

Example :


<?php
echo mt_rand() . "n";
echo mt_rand() . "n";
echo mt_rand(4, 18);
?>
Result :

1704545873
1573575755
7

In the above example the first the random values are returned without parameters, in the other statement a random number is displayed between "4" and "18".

PHP Topics


Ask Questions

Ask Question