时间:2021-07-01 10:21:17 帮助过:9人阅读
$bl = lucker(50);//50%的可能性
var_dump($bl);
function lucker($dot) {
$dot = intval($dot);
$dot = max($dot,0);//min dot = 0
$dot = min($dot,100);//max dot = 100
$one = rand(1,100);
$total = range(1,100);
shuffle($total);
$range = array();
for($i=0; $i<$dot; $i++) {
$range[] = $total[$i];
}
return in_array($one,$range);
}
?>
http://www.bkjia.com/PHPjc/508501.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/508501.htmlTechArticle给定一个概率(这里是点数),确定某次事件是否发生. 可以用在根据用户获得的点数,随机产生网站幸运星等方面(注意:这里有个等字). ?php /*...