To get a uniformly distributed random number in PHP, you can use the rand() or mt_rand() functions. Both functions generate a random integer between two given values.
For example, to generate a random integer between 1 and 10, you can use the rand() function like this:
main.php41 chars3 lines
Alternatively, you can use the mt_rand() function, which is generally faster and uses the Mersenne Twister algorithm for generating random numbers:
main.php44 chars3 lines
Both functions will return a random integer between 1 and 10 with a uniform distribution.
gistlibby LogSnag