According to the PHP documentation, if you're using PHP 7 you can generate a cryptographically secure pseudorandom integer using random_int
With that said, here's a function that utilizes this to generate a random float between two numbers:
function random_float($min, $max) {
return random_int($min, $max - 1) + (random_int(0, PHP_INT_MAX - 1) / PHP_INT_MAX );
}
Although random_int() is more secure than mt_rand(), keep in mind that it's also slower.
A previous version of this answer suggested you use PHP rand(), and had a horrible implementation. I wanted to change my answer without repeating what others had already stated, and now here we are.