php mt_rand() random number function_PHP tutorial

WBOY
Release: 2016-07-20 11:02:21
Original
1474 people have browsed it

php tutorial mt_rand() random number function
mt_rand() returns a random integer using the mersenne twister algorithm.

Grammar
mt_rand(min,max) description
If the optional arguments min and max are not provided, mt_rand() returns a pseudorandom number between 0 and rand_max. For example, if you want a random number between 5 and 15 (inclusive), use mt_rand(5, 15).

In versions prior to 3.0.7, max meant range. To get the same random numbers from 5 to 15 as in the above example in these versions, the short example is mt_rand (5, 11).
*/

$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";
}


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445361.htmlTechArticlephp tutorial mt_rand() random number function mt_rand() returns a random integer using the mersenne twister algorithm. Syntax mt_rand(min,max) description If the optional parameters min and max are not provided, mt_r...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template