php实现可以设置中奖概率的抽奖程序代码分享_PHP教程

WBOY
Libérer: 2016-07-13 10:40:44
original
679 Les gens l'ont consulté

复制代码 代码如下:

/**
 * 抽奖
 * @param int $total
 */
function getReward($total=1000)
{
 $win1 = floor((0.12*$total)/100);
 $win2 = floor((3*$total)/100);
 $win3 = floor((12*$total)/100);
 $other = $total-$win1-$win2-$win3;
 $return = array();
 for ($i=0;$i {
  $return[] = 1;
 }
 for ($j=0;$j {
  $return[] = 2;
 }
 for ($m=0;$m {
  $return[] = 3;
 }
 for ($n=0;$n {
  $return[] = '谢谢惠顾';
 }
 shuffle($return);
 return $return[array_rand($return)];
}

$data = getReward();
echo $data;
?>

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/714948.htmlTechArticle复制代码 代码如下: ?php /** * 抽奖 * @param int $total */ function getReward($total=1000) { $win1 = floor((0.12*$total)/100); $win2 = floor((3*$total)/100); $win3 = floor...
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!