Two methods to randomly generate a lucky two-color ball number using php _ PHP Tutorial

Source: Internet
Author: User
You can use php to randomly generate a lucky two-color ball number. I don't want to tell you that I am also a two-color ball enthusiast. I often buy it, but I haven't won the first prize yet, haha. Here we will introduce you to two ways to randomly generate a lucky two-color ball number using php. I am also a two-color ball enthusiast and often buy it, but I have never won the first prize yet, haha.
Here we will introduce two methods to randomly generate a lucky two-color ball number using php for your reference. In the new year, I wish you a grand prize and a fortune.

Method 1

The code is as follows:


/*
Generate a random color ball number
*/
$ Red = array (, 33 );
$ Blue = array );
For ($ I = 0; $ I <6; $ I ++ ){
$ Index = rand (0, 32-$ I );
$ RedBall [] = $ red [$ index];
Unset ($ red [$ index]);
For ($ k = $ index; $ k $ Red [$ k] = $ red [$ k + 1];
}
}
Asort ($ redBall );
?>


Foreach ($ redBall as $ v ){
Echo $ v ."";
}
?>



Echo $ blue [rand (0, 15)];
?>



Method 2

The code is as follows:


/*
Generate a random color ball number
*/
Echo"
";
Echo"

";
$ Red1 = range (1, 33 );
$ Blue1 = mt_rand (1, 6 );
$ Sc1 = array_rand ($ red1, 6 );
?>


Foreach ($ sc1 as $ v ){
Echo "$ v ";
}
?>



Echo "$ blue1 ";
?>



The previous method is relatively troublesome. if you need it, please refer to the second method.

Bytes. Here we will introduce two methods to randomly generate a lucky two-color ball number using php...

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.