博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
php大转盘抽奖
阅读量:5100 次
发布时间:2019-06-13

本文共 1586 字,大约阅读时间需要 5 分钟。

抽奖大转盘演示:http://www.sucaihuo.com/php/3301.htmlfunction getRand($proArr, $proCount) {     $result = '';     $proSum = 0;     foreach ($proCount as $key => $val) {         if ($val <= 0) {             continue;         } else {             $proSum = $proSum + $proArr[$key];         }     }     foreach ($proArr as $key => $proCur) {         if ($proCount[$key] <= 0) {             continue;         } else {             $randNum = mt_rand(1, $proSum);             if ($randNum <= $proCur) {                 $result = $key;                 break;             } else {                 $proSum -= $proCur;             }         }     }     unset($proArr);     return $result; }
$prizes = array(         0 => array(             "id" => 0, //中奖id             "name" => "谢谢参与", //奖品名称             "count" => "100", //库存         ),         1 => array(             "id" => 1,             "name" => "罗浮山门票",             "count" => "40",         ),         2 => array(             "id" => 2,             "name" => "罗浮山嘉宝田温泉体验券",             "count" => "40",         ),         3 => array(             "id" => 3,             "name" => "精美旅游书籍《山水酿惠州》",             "count" => "40",         ),         4 => array(             "id" => 4,             "name" => "碧海湾漂流门票",             "count" => "40",         ),         5 => array(             "id" => 5,             "name" => "南昆山门票",             "count" => "40",         ),         6 => array(             "id" => 6,             "name" => "云顶温泉精美礼品",             "count" => "40",         ),     );

 

转载于:https://www.cnblogs.com/lglblogadd/p/8259940.html

你可能感兴趣的文章
Visual Studio基于CMake配置opencv1.0.0、opencv2.2
查看>>
Vue音乐项目笔记(三)
查看>>
遍历Map对象
查看>>
计算剪贴板里仿制的代码行数
查看>>
MySQL索引背后的数据结构及算法原理
查看>>
#Leetcode# 209. Minimum Size Subarray Sum
查看>>
SDN第四次作业
查看>>
DM8168 DVRRDK软件框架研究
查看>>
django迁移数据库错误
查看>>
yii 跳转页面
查看>>
洛谷 1449——后缀表达式(线性数据结构)
查看>>
[最小割][Kruskal] Luogu P5039 最小生成树
查看>>
Data truncation: Out of range value for column 'Quality' at row 1
查看>>
Dirichlet分布深入理解
查看>>
(转)Android之发送短信的两种方式
查看>>
python第九天课程:遇到了金角大王
查看>>
字符串处理
查看>>
ECharts(Enterprise Charts 商业产品图表库)初识
查看>>
LeetCode Factorial Trailing Zeroes (阶乘后缀零)
查看>>
hdu 5402 Travelling Salesman Problem (技巧,未写完)
查看>>