标签:试题 面试 and cti turn func return reac fun
同事说的一道面试题
function r($data){ $n = rand(0,100); $temp = 0; foreach ($data as $k => $v) { $temp+=$v; if($n<=$temp) { return $k; } } return false; } $r = r(["t"=>0.1,"1"=>0.5,"2"=>1.5,"3"=>10,"4"=>20]); echo $r==false?"未中奖":$r."等奖";
标签:试题 面试 and cti turn func return reac fun
原文地址:https://www.cnblogs.com/samxiong/p/10923556.html