2 ways to randomly generate lottery shuangse qiu numbers in PHP _php techniques

Source: Internet
Author: User
Tags rand

I do not deceive you said, I am also a shuangse qiu enthusiasts, often buy, but the delay has not been the first prize, haha.
Here for you to introduce a random generation of PHP lottery Shuangse Qiu number two ways for friends to learn the reference. In the new year, I wish you all a big prize and a great fortune.

Method One

Copy Code code as follows:

<?php
/*
Randomly generated lottery Shuangse qiu number
*/
$red = Array (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33);
$blue = Array (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16);
For ($i =0 $i <6; $i + +) {
$index = rand (0,32-$i);
$redBall []= $red [$index];
Unset ($red [$index]);
for ($k = $index; $k <count ($red)-1; $k + +) {
$red [$k]= $red [$k +1];
}
}
Asort ($redBall);
?>
<div style= "Background-color:red;color:white;width:160px;float:left;text-align:center;" >
<?php
foreach ($redBall as $v) {
echo $v. " ";
}
?>
</div>
<div style= "Background-color:blue;color:white;width:40px;float:left;text-align:center" >
<?php
echo $blue [rand (0,15)];
?>
</div>

Method Two
Copy Code code as follows:

<?php
/*
Randomly generated lottery Shuangse qiu number
*/
echo "<br>";
echo "<p>";
$red 1=range (1,33);
$blue 1=mt_rand (1,6);
$SC 1=array_rand ($red 1,6);
?>
<div style= "Background-color:red;color:white;width:160px;float:left;text-align:center;" >
<?php
foreach ($sc 1 as $v) {
echo "$v";
}
?>
</div>
<div style= "Background-color:blue;color:white;width:40px;float:left;text-align:center" >
<?php
echo "$blue 1";
?>
</div>

The previous method is relatively troublesome, the need for friends, may wish to refer to the second method.

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.