PHP mt_srand() Function
Example
Seed the random number generator:
<?php
mt_srand(mktime());
echo(mt_rand());
?>
Try it Yourself »
Definition and Usage
The mt_srand() function seeds the Mersenne Twister random number generator.
Syntax
mt_srand(seed, mode);
Parameter Values
Parameter | Description |
---|---|
seed | Optional. Specifies the seed value |
mode | Optional. Specifies the algorithm to use. Can be one of the following constants:
|
Technical Details
Return Value: | None |
---|---|
Return Type: | - |
PHP Version: | 4+ |
PHP Changelog: | PHP 4.2.0: Random number generator is now seeded automatically |
❮ PHP Math Reference