PHP彩票随机生成程序
作者:ainy 日期:2009-05-20
喜欢买彩票的研究一下喽
<table width="400" border="1" cellspacing="0" cellpadding="0" >
<?php
for ($n=1;$n<=20;$n++) {
echo "<tr><td bgcolor=#cccccc width=80>第".$n."注 </td>";
$string="";//初始化字符串
for ($i=1;$i<=7;$i++) {
mt_srand((double)microtime()*1000000);//加入时间的因素,以执行时的百万分之一秒当乱数种子
$random=mt_rand(1,30);//产生1-30间的随机数
if (eregi($random,$string)){//检查此数是否已经存在
$i--;
continue;//跳出循环,回到判断起始处。
}
else{
$string=$string.",".$random;
echo "<td bgcolor=#efefef>";
echo $random," ";}
}
echo "</td></tr>";
}
?>
</table>
<table width="400" border="1" cellspacing="0" cellpadding="0" >
<?php
for ($n=1;$n<=20;$n++) {
echo "<tr><td bgcolor=#cccccc width=80>第".$n."注 </td>";
$string="";//初始化字符串
for ($i=1;$i<=7;$i++) {
mt_srand((double)microtime()*1000000);//加入时间的因素,以执行时的百万分之一秒当乱数种子
$random=mt_rand(1,30);//产生1-30间的随机数
if (eregi($random,$string)){//检查此数是否已经存在
$i--;
continue;//跳出循环,回到判断起始处。
}
else{
$string=$string.",".$random;
echo "<td bgcolor=#efefef>";
echo $random," ";}
}
echo "</td></tr>";
}
?>
</table>
评论: 0 | 引用: 0 | 查看次数: -
发表评论
上一篇
下一篇

文章来自:
Tags: