mt_srand

void mt_srand(int seed) 

Seeds the random number generator for mt_rand() .

Returns:

Nothing

Description:

This function seeds the random number generator for mt_rand(). The greater the randomness of the initial seed passed to this function, the better the randomness of the numbers later generated by mt_rand().

This function needs to be called only once per script, before any calls to mt_rand().

Version:

PHP 3 since 3.0.6, PHP 4

See also:

getrandmax() 
mt_getrandmax() 
mt_rand() 
rand() 
srand() 

Example:

Seed the Mersenne Twister random number generator
mt_srand((double) microtime() * 1000000); 

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.