mt_rand

int mt_rand(int min, int max) 

Generates a random integer using the Mersenne Twister algorithm.

Returns:

Random integer

Description:

Calling this function without any arguments produces a random number between zero and the system’s maximum Mersenne Twister value. The maximum value can be found by calling mt_getrandmax(). Passing both the min and max arguments generates a number within the provided range.

Whereas rand() uses the standard libc rand() function, which can be slow and doesn’t have a set of known characteristics, mt_rand() uses the Mersenne Twister algorithm to generate a random number that’s more suitable for cryptography because of its known characteristics. This function can also be up to four times faster than the standard ...

Get PHP Functions Essential Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.