Many random number generators of older libcs have dubious or unknown characteristics and are slow. By default, PHP uses the libc random number generator with the rand() function. The mt_rand() function is a drop-in replacement for this. It uses a random number generator with known characteristics using the « Mersenne Twister », which will produce random numbers four times faster than what the average libc rand() provides.
If called without the optional $min, $max arguments mt_rand() returns a pseudo-random value between 0 and mt_getrandmax(). If you want a random number between 10 and 100 (inclusive), for example, use mt_rand(10, 100).
declaration of mt_rand
int mt_rand ( [int $min ] [, int $max ] )
test mt_rand online
comments for mt_rand
be the first
No comments so far for mt_rand(). Leave yours as first below.