Hi! Could we please enable some services and cookies to improve your experience and our website?
Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code
<?php
$params['timestamp'] = number_format(microtime(true) * 1000, 0, '.', '');
echo $params['timestamp'];
function float_rand($Min, $Max, $round=0){
//validate input
if ($Min>$Max) { $min=$Max; $max=$Min; }
else { $min=$Min; $max=$Max; }
$randomfloat = $min + mt_rand() / mt_getrandmax() * ($max - $min);
if($round>0)
$randomfloat = round($randomfloat,$round);
return $randomfloat;
}
$x = 125000; // само число
// ---------------------------
$min = 13000; // минимум
$max = 13800; // максимум
// ---------------------------
$kop = true; // с копейками flase or true
$i=1;
do
{
if ($kop) {
$temp[$i] = float_rand($min, $max, 2);
} else {
$temp[$i] = mt_rand($min, $max);
}
if ($x - $temp[$i] >=0) {
$x = $x - $temp[$i];
$i++;
}
// print_r($x);
} while ($x > $min);
$temp[$i] = round($x,2);
print_r($temp);
print_r('Сумма: '.array_sum($temp));