mt_rand & mt_getrandmax functions
<?php
function generateRandomFloat(float $minValue, float $maxValue): float
{
return $minValue + mt_rand() / mt_getrandmax() * ($maxValue - $minValue);
}
$minValue = 10.5;
$maxValue = 20.5;
$randValue = generateRandomFloat($minValue, $maxValue);
echo $randValue;
Leave a Comment
Cancel reply