I am new to PHP so sorry if this is messy, I have looked around StackOverflow but I am unable to find anything that fits my need.
I am trying to create a random float number list. But the problem I am having is everytime I run the list it prints out the same number. Can anyone explain why and if there is a way to get different numbers each iteration.
Thank You for any help.
<?php
function frand($min, $max, $decimals = 0) {
mt_srand(microtime());
$scale = pow(10, $decimals);
return mt_rand($min * $scale, $max * $scale) / $scale;
}
for ($x = 1; $x <= 45; $x++) {
echo frand(1, 17, 8) . "<br/>";
}
?>
Aucun commentaire:
Enregistrer un commentaire