php大转盘抽奖

Posted lgl的守望地盘

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php大转盘抽奖相关的知识,希望对你有一定的参考价值。

抽奖大转盘演示:http://www.sucaihuo.com/php/3301.html
function 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", 
        ), 
    );
    

 

以上是关于php大转盘抽奖的主要内容,如果未能解决你的问题,请参考以下文章

PHP实现大转盘抽奖算法实例

PHP实现刮刮卡,大转盘抽奖概率,其实很简单!

php大转盘抽奖

jQuery幸运大转盘_jQuery+PHP抽奖程序的简单实现

幸运大转盘-jQuery+PHP实现的抽奖程序

PHP新写的大转盘抽奖源码