使用PHP生成两个小数之间的随机小数 [英] Use PHP To Generate Random Decimal Beteween Two Decimals
本文介绍了使用PHP生成两个小数之间的随机小数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要生成一个随机数,在PHP的2个小数点之间达到第10位.
I need to generate a random number, to the 10th spot between 2 decimals in PHP.
例如在1.2到5.7之间的兰特数.它将返回3.4
Ex. A rand number between 1.2 and 5.7. It would return 3.4
我该怎么做?
推荐答案
您可以使用:
rand ($min*10, $max*10) / 10
甚至更好:
mt_rand ($min*10, $max*10) / 10
这篇关于使用PHP生成两个小数之间的随机小数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文