Answers for "create random numbers with decimal in php"

PHP
1

php random float number with 2 decimal places

$decimals = 2; // number of decimal places
$div = pow(10, $decimals);

// Syntax: mt_rand(min, max);
mt_rand(0.01 * $div, 0.05 * $div) / $div;
Posted by: Guest on March-02-2021
0

php randon integer 4 digit

$digits = 3;
echo rand(pow(10, $digits-1), pow(10, $digits)-1);
Posted by: Guest on February-28-2021

Code answers related to "create random numbers with decimal in php"

Browse Popular Code Answers by Language