导航:首页 > 源码编译 > 姓名抽奖php源码

姓名抽奖php源码

发布时间:2024-11-09 17:14:41

‘壹’ php抽奖问题,奖项id为1的一等奖,每天只能出现一次,该怎么实现;

保存 一等奖 和 抽奖时间。如果今天一等奖已经抽中了,就跳过。

‘贰’ php实现可以设置中奖概率的抽奖程序代码分享

这篇文章主要介绍了一个抽奖程序,要求一等奖的中奖概率是0.12%,二等奖中奖概率是3%,三等奖中奖概率是12%,其他中奖概率是都是谢谢惠顾
代码如下:
<?php
/**
*
抽奖
*
@param
int
$total
*/
function
getReward($total=1000)
{
$win1
=
floor((0.12*$total)/100);
$win2
=
floor((3*$total)/100);
$win3
=
floor((12*$total)/100);
$other
=
$total-$win1-$win2-$win3;
$return
=
array();
for
($i=0;$i<$win1;$i++)
{

$return[]
=
1;
}
for
($j=0;$j<$win2;$j++)
{

$return[]
=
2;
}
for
($m=0;$m<$win3;$m++)
{

$return[]
=
3;
}
for
($n=0;$n<$other;$n++)
{

$return[]
=
'谢谢惠顾';
}
shuffle($return);
return
$return[array_rand($return)];
}

$data
=
getReward();
echo
$data;
?>

‘叁’ php 抽奖代码,100分奖励

中奖概率是40%

<?php
/**
* 抽奖
* @param int $total
*/
function getReward($total=1000)
{
$win1 = floor((40*$total)/100);
$other = $total-$win1;
$return = array();
for ($i=0;$i<$win1;$i++)
{
$return[] = 1;
}

for ($n=0;$n<$other;$n++)
{
$return[] = '未抽中奖品';
}
shuffle($return);
return $return[array_rand($return)];
}
$data = getReward();
echo $data;
?>

阅读全文

与姓名抽奖php源码相关的资料

热点内容
gcccreate命令 浏览:73
海尔监控用什么app 浏览:64
系统盘被压缩开不了机 浏览:984
linuxredis30 浏览:541
狸窝pdf转换器 浏览:696
ajax调用java后台 浏览:904
活塞式压缩机常见故障 浏览:614
break算法 浏览:731
换电池的app是什么 浏览:771
单片机ad采样快速发送电脑 浏览:22
第五人格服务器错误是什么回事儿 浏览:467
查看手机谷歌服务器地址 浏览:191
python操作zookeeper 浏览:706
苹果手机dcim文件夹显示不出来 浏览:430
如何压缩文件夹联想电脑 浏览:584
程序员的学习之旅 浏览:441
apkdb反编译 浏览:922
雪花算法为什么要二进制 浏览:825
在文档中打开命令行工具 浏览:608
android图标尺寸规范 浏览:369