Php mt_rand () random number function

Source: Internet
Author: User

Php 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_rand () returns a pseudo-random number between 0 and rand_max. For example, if you want a random number between 5 and 15 (including 5 and 15), use mt_rand (5, 15 ).

In versions earlier than 3.0.7, max indicates range. In these versions, we need to obtain a random number from 5 to 15, which is the same as the preceding example. The short example is mt_rand (5, 11 ).
*/

$ Rand = mt_rand (0, 1 );
If ($ rand = 0)
 {
$ Array = array (, 30 );
 }
Elseif ($ rand = 1)
 {
$ Array = array (37,400,444 );
 }

Foreach ($ array as $ v => $ vv)
 {
  
Echo "$ vvn ";
 }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.