Home  >  Article  >  Backend Development  >  php mt_rand() random number function_PHP tutorial

php mt_rand() random number function_PHP tutorial

WBOY
WBOYOriginal
2016-07-20 11:02:211438browse

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...
Statement:
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