导航:首页 > 源码编译 > 姓名抽奖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源码相关的资料

热点内容
时钟置换算法指针变化规则 浏览:245
微信加密能否改密码 浏览:104
android权限组 浏览:169
2017单片机 浏览:475
让孩子感兴趣编程的电影 浏览:259
用颜料制作脆皮解压球 浏览:932
火箭解压器 浏览:72
cnet中级程序员面试题 浏览:190
单片机怎么做人脸识别 浏览:152
监狱办理工商银行app怎么办呢 浏览:818
c语言写编程时需要用什么输入法 浏览:590
生发程序员 浏览:165
高考英语pdf 浏览:418
哈利波特忘记服务器怎么办 浏览:824
怎么看其他电脑共享文件夹 浏览:513
py文件夹后缀 浏览:723
你对我们的app有什么建议 浏览:584
phpgetcookie 浏览:145
程序员最烦遇到的单词 浏览:125
开始服务器升级需要什么 浏览:985