← All built-ins / mt_srand()

mt_srand()

mt_srand(...$args): void

Parameters

NameTypeDescription
$seedintseed value

Return value

Seeds mt_rand() for reproducible sequences.

Example

mt_srand(7);
$a = mt_rand(0, 1000);
mt_srand(7);
$b = mt_rand(0, 1000);
echo $a == $b ? "reproducible" : "random";
reproducible

See also

mt_rand()srand()