Generate random decimal numbers

I have two numbers 1.5 and 2.5
Question: How to generate random numbers in this range? rand/mt_rand are rounded up to integer values, i.e. outputs either 1 or 2.

Answer 1, authority 100%

Use the function lcg_value. In the function examples, there are options for generating a real number within the specified range.

Answer 2, authority 100%

$rand = rand(15,25)/10;


Answer 3

Well, if the range is so small, you can write an array of this range from 1.5 to 2.5 and mt_rand work on the array key.