How does one generate a random float between 0 and 1 in PHP?
I\'m looking for the PHP\'s equivalent to Java\'s Math.random().
Math.random()
function frand($min, $max, $decimals = 0) { $scale = pow(10, $decimals); return mt_rand($min * $scale, $max * $scale) / $scale; } echo "frand(0, 10, 2) = " . frand(0, 10, 2) . "\n";