- <?php
- defined('ROOT') or exit('Access Denied');
- class Probob{
- public function getProbobAward($array){
- $Sum = array_sum($array);
- foreach($array as $key => $prob){
- $Rand = mt_rand(1, $Sum);
- if($Rand <= $prob){
- return $key;
- }else{
- $Sum -= $prob;
- }
- }
- }
- }
- //该片段来自于http://www.codesnippet.cn/detail/1707201513145.html
来源: http://www.codesnippet.cn/detail/1707201513145.html