PHP mt_srand()Function
Examples
Seed the random number generator:
<?php
mt_srand(mktime());
echo(mt_rand());
?>
mt_srand(mktime());
echo(mt_rand());
?>
Run example »
Definition and Usage
The mt_srand() function seeds the Mersenne Twister random number generator.
Tip:As of PHP 4.2.0, the random number generator is automatically seeded, so there is no need to use this function.
Syntax
mt_srand(seed);
| Parameter | Description |
|---|---|
| seed | Optional. Specifies the seed value. |
Technical Details
| Return value: | None. |
|---|---|
| Return type: | - |
| PHP Version: | 4+ |
| PHP Changelog: | PHP 4.2.0: The random number generator is automatically seeded. |
PHP Math Reference Manual Other Extensions