tags:

views:

75

answers:

4

How random is rand(), and is there a solution for generating more random numbers?

+1  A: 

http://php.net/mt_rand

is better than rand()

smoove666
+6  A: 

How about mt_rand(), which uses the Mersenne Twister. It should generate random numbers up to the size of an int. (use mt_getrandmax() to get the maximum value).

Dmitry Brant
+2  A: 

There is a better random number generator (which is referenced in the 'see also' section of the documentation of rand(), by the way): mt_rand()

soulmerge
Slower - really? docs say its 4 times faster: "... which will produce random numbers four times faster than what the average libc `rand()` provides."
Dominic Rodger
Woops, sorry. Fixed the answer.
soulmerge
A: 

You can use this function from the mt_rand notes in the function documentation http://www.php.net/manual/en/function.mt-rand.php#83358

inakiabt