当前位置:网站首页>Assign a specified amount to a specified number of people at random
Assign a specified amount to a specified number of people at random
2022-06-12 10:30:00 【P P PHP】
function getRandMoney($money_total,$personal_num){
$min_money=0.01;// Minimum available amount
$money_right=$money_total;
$randMoney=[];
for($i=1;$i<=$personal_num;$i++){
if($i== $personal_num){
$money=$money_right;
}else{
$max=$money_right*100 - ($personal_num - $i ) * $min_money *100;
$money= rand($min_money*100,$max) /100;
$money=sprintf("%.2f",$money);
}
$randMoney[]=$money;
$money_right=$money_right - $money;
$money_right=sprintf("%.2f",$money_right);
}
return $randMoney;
}
//3 Individual random assignment 10 element
print_r(getRandMoney(10,3));边栏推荐
- Valentina Studio Pro for MAC (MAC database management software)
- Simple use of autojs
- np. Meshgrid() function and coordinate position generation in 3D space and numpy Introduction to repeat() function
- 使用cpolar远程办公(2)
- Wechat payment, wechat refund, Alibaba payment
- 一测两三年,记测试交流经验的一些感想
- [CEGUI] font loading optimization
- 性能指标的信仰危机
- Leetcode 2169. 得到 0 的操作数
- PHP interface generates cache and MD5 encryption uniformly
猜你喜欢
![[MySQL] index invalidation and index optimization](/img/af/9ed540aab764f4962ccc9bbfe406f3.jpg)
[MySQL] index invalidation and index optimization

Qt自定义窗口圆角

Leetcdoe 2037. 使每位学生都有座位的最少移动次数(可以,一次过)

Solution to invalid small program scroll into view

Leetcode2154. 将找到的值乘以 2(二分查找)

远程桌面不能复制粘贴解决办法

Leetcode 2169. 得到 0 的操作数

Win10 professional edition user name modification

Dynamic proxy

Circuitbreaker fuse of resilience4j -- Measurement of circuitbreakermetrics index
随机推荐
Timers in golang
np. Meshgrid() function and coordinate position generation in 3D space and numpy Introduction to repeat() function
Php:redis uses geospatial
Add jar package under idea2018 web project
93. obtain all IP addresses of the Intranet
Chapter 3 search
XML Parsing Error: mismatched tag. Expected
How to play the 2022 Taobao 618 Super Cat Games? What are the strategies for the Super Cat Games
pycharm 查看opencv当前的版本
A hundred secrets and a few secrets - Caesar encryption
High performance computing framework for image processing
[CEGUI] concept introduction
On the improvement of 3dsc by harmonic shape context feature HSC
PHP: seven cattle cloud upload file
Download Notepad++
JS string combination
93. Obtenir toutes les adresses IP de l'Intranet
Leetcode2154. Multiply the found value by 2 (binary search)
2022淘宝618超级喵运会玩法攻略 618超级喵运会玩法技巧
ASP.NET Core权限系统实战(零)