標題:
樂透開獎程式進階版0928
[打印本頁]
作者:
may
時間:
2011-5-29 10:38
標題:
樂透開獎程式進階版0928
<?php
$your = array("6","25","22","16","17","18");
//mt_srand((double)microtime()*1000000);
$lottery[] = array();
$n = 6;
for ($i = 1; $i <= $n; $i++) {
$number = rand(1,42);
if (in_array($number, $lottery)) { //如果已產生過迴圈重跑 in_array --- 搜尋陣列中值是否存在
$i--;
}else{
$lottery[] = $number; //若無重復則 將亂數塞入陣列
}
}
echo "中獎號碼 : ";
for ($i = 1; $i <= $n; $i++) {
for ($j = 0; $j < $n; $j++) {
// echo $lottery[$i];
// echo $your[$i-1];
if($lottery[$i] == $your[$j])
echo $lottery[$i]." ";
}
}
?>
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2