编程语言
首页 > 编程语言> > php年会抽奖

php年会抽奖

作者:互联网

原文链接:http://www.cnblogs.com/bwzhangtao/p/4233354.html

<?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;
?>

转载于:https://www.cnblogs.com/bwzhangtao/p/4233354.html

标签:getReward,www,php,return,floor,抽奖,年会,100,total
来源: https://blog.csdn.net/weixin_30905981/article/details/99592049