submitted by: ncali
PHP: generate random number
Generate a random number using mt_rand. From the php documentation- "If called without the optional min, max arguments mt_rand() returns a pseudo-random value between 0 and RAND_MAX. If you want a random number between 5 and 15 (inclusive), for example, use mt_rand (5, 15)."
code snippet:
<?php
echo mt_rand() . "\n";
echo mt_rand() . "\n";
//generate random number between 5 and 15
echo mt_rand(5, 15);
?>
sample output:
1604716014
1478613278
6
1478613278
6
notes:
Of course if you try this code, your numbers should not be the same ;)



