Alexey Berezuev - 3 months ago 80

PHP Question

`$a = floatval(0.0001);`

$b = floatval(0.0009);

$c = rand($a,$b); // int(0);

How can I get rand from

`$a`

`$b`

Multiplication of

`$`

`$b`

Answer

From this article:

An elegant way to return random float between two numbers:

```
function random_float ($min,$max) {
return ($min+lcg_value()*(abs($max-$min)));
}
```