rand

int rand([int rmin], [int rmax]) 

Generates a random integer.

Returns:

Random integer

Description:

The rand() function returns a random integer between zero and the maximum random value for the system, which you can determine by using getrandmax(). Optional arguments can be used to limit the range of the returned value, as long as rmax is less than or equal to the value returned by getrandmax(). To maximize the randomness of the returned value, it’s always a good idea—but not essential— to seed the random number generator using srand(). If one argument is passed, both arguments must be passed; otherwise, the call will generate a warning.

Note that the mt_rand() function, which uses the Mersenne Twister algorithm to generate random numbers, ...

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.