PHP mt_srand() Function
In this chapter you will learn:
- Definition for PHP mt_srand() Function
- Syntax for PHP mt_srand() Function
- Parameter for PHP mt_srand() Function
- Return for PHP mt_srand() Function
- Example - seed a random value
Definition
The mt_srand() function seeds the Mersenne Twister random number generator.
Syntax
PHP mt_srand() Function has the following syntax.
mt_srand(seed);
Parameter
Parameter | Is Required | Description |
---|---|---|
seed | Optional. | Seed value |
Return
None
Example
Seed the random number generator:
<?php
mt_srand(mktime());
echo(mt_rand());
?>
The code above generates the following result.
Next chapter...
What you will learn in the next chapter:
- Definition for PHP octdec() Function
- Syntax for PHP octdec() Function
- Parameter for PHP octdec() Function
- Return for PHP octdec() Function
- Example - Convert octal to decimal
Home » PHP Tutorial » PHP Math Functions