Questions Regarding "Randomizing"
Posted: Sun Oct 27, 2002 1:02 pm
Hey all,
Since I'm still very new to PHP, I decided to learn how to randomize things. First I tried returning random numbers. Here's the script:
I don't believe there's any errors in the code, but no matter how many times i refresh, the only numbers returned are 7, 8, 9, and 10. Why don't the numbers 0-6 ever get returned?
My next question is, what exactly does the "(double)" -
in that line mean? Where can I learn about it?
Also, regarding the count() function - When it counts, does it start at 1 instead of 0?
Thanks for your help. - Tom
Since I'm still very new to PHP, I decided to learn how to randomize things. First I tried returning random numbers. Here's the script:
Code: Select all
<?php
srand((double)microtime()*1000000);
$randomNo = rand(0,10);
echo $randomNo;
?>My next question is, what exactly does the "(double)" -
Code: Select all
srand((double)microtime()*1000000);Also, regarding the count() function - When it counts, does it start at 1 instead of 0?
Thanks for your help. - Tom