Это оказалось самым сложным.
$count_arr = 3000;
$count_chunk = 20;
$int_min = 100;
$int_max = 200;
$array = array_fill(0, $count_chunk, floor($count_arr / $count_chunk) );
for($i=0;$i<1000;$i++)
{
$rand = rand(1, 10);
if($array[0] > ($rand + $int_min) and $array[1] < ($int_max - $rand))
{
$array[0] = $array[0] - $rand;
$array[1] = $array[1] + $rand;
shuffle($array);
}
}
Это вернет нам такой вспомогательный массив
Array
(
[0] => 146
[1] => 199
[2] => 186
[3] => 145
[4] => 158
[5] => 153
[6] => 174
[7] => 149
[8] => 107
[9] => 164
[10] => 159
[11] => 123
[12] => 124
[13] => 125
[14] => 134
[15] => 127
[16] => 148
[17] => 126
[18] => 197
[19] => 156
)
array_sum($array); // 3000
А дальше просто режем массив
$apple_array = range(0,3000);
for($i=0;$i<20;$i++)
{
$out[] = array_slice($apple_array, 0, $array[$i]);
array_splice($apple_array, 0, $array[$i]);
}