dimanche 22 février 2015

Php random number generate

My task:


Generate random numbers between 1 and 20, to 1 decimal place.


However my issue as simple as mt_rand. I want most of the numbers generated to be lower around 0.5 - 4.5 with the occasional number being between 4.5-10 and very rarely say once every 12-20 hours being between 10-20.


I've been using the following but have no idea where to go from. I am a very basic self teaching programmer.



$min = 1;
$max = 20;
$suisse_interest = mt_rand ($min*10, $max*10) / 10


Maybe if I briefly explain why I want this it may help..


I own an online game and want to add 3 "banks" with each bank generating different interests each hour. Most of the time I want it low, but sometimes higher and very rarely very high (15-20%).


With the above code the random number goes too high to often.


Any help with this is greatly appreciated!





Aucun commentaire:

Enregistrer un commentaire