Skip to content

Instantly share code, notes, and snippets.

@sooch
Created December 28, 2018 08:31
Show Gist options
  • Save sooch/6eea320aa5111af8f56dfeb24893f9c7 to your computer and use it in GitHub Desktop.
Save sooch/6eea320aa5111af8f56dfeb24893f9c7 to your computer and use it in GitHub Desktop.
random number between a float range for PHP
/**
* 範囲内の値をランダムで返す
*
* @param float $min 最小値
* @param float $max 最大値
* @return float
*/
function random_float($min, $max, $mul = 1000000): float
{
return random_int($min * $mul, $max * $mul) / $mul;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment