Created
March 8, 2016 06:43
-
-
Save techom/7622b85c6281e78a13a0 to your computer and use it in GitHub Desktop.
Revisions
-
techom created this gist
Mar 8, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ header("Content-Type: text/html;charset=utf-8"); $total=10; // 红包总额 $num=8; // 分成8个红包,支持8人随机领取 $min=0.01; // 每个人最少能收到0.01元 for ($i=1;$i<$num;$i++) { $safe_total = ($total-($num-$i)*$min)/($num-$i); //随机安全上限 $money = mt_rand($min*100, $safe_total*100)/100; $total = $total - $money; echo '第'.$i.'个红包:'.$money.' 元,余额:'.$total.' 元 <br/>'; } echo '第'.$num.'个红包:'.$total.' 元,余额:0 元';