You can generate a random float number between 0 and 1 in PHP using the rand
function. Here's an example:
main.php59 chars3 lines
The rand()
function generates a random integer. getrandmax()
returns the maximum value that can be returned by rand()
. Dividing the random integer by getrandmax()
gives you a float number between 0 and 1.
gistlibby LogSnag