<?php
function cut(int $total) {
$result = [];
while ($total > 0) {
$new = random_int(1, $total);
$result []= $new;
$total -= $new;
}
shuffle($result);
return $result;
}
function repr_array(array $arr) {
$result = [];
foreach ($arr as $item) {
$result []= $item;
}
return '['.implode(', ', $result).']';
}
$max = random_int(100000, 500000);
echo $max, ' = ', repr_array(cut($max)), "\n";
To embed this program on your website, copy the following code and paste it into your website's HTML: