1 |
|
使用示例:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
$prizes = array(
array('id' => 1, 'name' => '小米手机', 'probability' => '0.009'),
array('id' => 2, 'name' => 'iPhone 6s', 'probability' => '0.0001'),
array('id' => 3, 'name' => '优惠券300', 'probability' => '0.002'),
array('id' => 4, 'name' => '16G优盘', 'probability' => '0.01'),
);
while(true) {
shuffle($prizes);
foreach($prizes as $prize) {
$result = false;
if ($this->bingo($prize['probability'])) {
$result = $prize;
break;
}
}
if($result) {
break;
}
}
print_r($result);