This article illustrates the use of Mt_rand () random number functions in PHP. Share to everyone for your reference. The specific analysis is as follows:
Mt_rand () returns a random integer using the Mersenne twister algorithm.
Syntax: Mt_rand (Min,max)
Note: If you do not provide optional parameters min and Max,mt_rand () return the pseudo-random number between 0 and Rand_max, such as a random number between 5 and 15 (including 5 and 15), use Mt_rand (5,15).
In the previous version of 3.0.7, Max meant a range, and to get the same number of random numbers in these versions as the previous example is 5 to 15, the short example is Mt_rand (5, 11).
The PHP instance code is as follows:
Copy Code code as follows:
$rand = Mt_rand (0,1);
if ($rand ==0)
{
$array = Array (41,20,26,29,30);
}
ElseIf ($rand ==1)
{
$array = Array (38,42,37,400,444);
}
foreach ($array as $v => $vv)
{
echo "$VVN";
}
I hope this article will help you with your PHP program design.