The srand() function seeds the random number generator (rand()).
PHP srand() Function has the following syntax.
srand(seed);
Parameter | Description |
---|---|
seed | Optional. Specifies the seed value |
None
Seed the random number generator:
<?php
srand(mktime());
echo(rand());
?>
The code above generates the following result.