function getRand($proArr, $proCount) {

$result = '';

$proSum = 0;

抽奖程序思路phpPHP新写的年夜转盘抽奖源码 CSS

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://gitee.com/lanrenzhijia/codes/d342lk1yw5nm8x09euqag50