<?phpheader(‘Content-Type: text/html; charset=utf-8‘);//PHP实现双色球机选号码$red = range(1, 33);//初次设定红球号码//用函数array_rand随机选取6个红色号码$red1 = array_rand($red,6);/*由于array_rand的返回值是数组的索引,所以需要遍历此索引数组取出每个索引所对应的红球号码,然后组成新的6个红号数组*/$eRed = array();for ($i=0; $i <6; $i++) { ???$red2 = $red[$red1[$i]]; ???array_push($eRed, $red2);}?><div style="width: 150px; text-align: center; float: left; ???????background-color: red; color:black; "><?php//遍历红号数组,依次输出foreach ($eRed as $v) { ???echo($v).‘ ?‘;} ?> </div><div style="width: 50px; text-align: center; float: left; ???????background-color: blue; color:black;"><?php//用rand函数随机输出篮球号码echo ‘‘.(rand(1,16));?></div>
效果如下图:
PHP实现简单的双色球机选号码
原文地址:https://www.cnblogs.com/davis16/p/8628324.html