function rand_float($min, $max, $decimals = 0) {
$dec = pow(10, $decimals);
return mt_rand($min * $dec, $max * $dec) / $dec;
}
for ($i = 0; $i < 10; $i++) {
echo rand_float(0, 5, 2) . "\n";
}
/*
run:
4.64
1.61
2.15
3.14
1.63
4.27
3.75
3.76
2.93
0.4
*/