Home > PHP > Function > Math > mt_rand()

mt_rand()

mt_rand - Generate a better random value

Syntax

int mt_rand ()

Arguments

-

Description

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.

Version

PHP 4, 5

Return value

A random integer value between min (or 0) and max (or mt_getrandmax(), inclusive)