I have the following script that divides the total by the number of people and stores the results in an array.
Instead of dumping the $result array at the end, I wonder if I could echo out the value of each array item in the for loop as it goes?
// initial conditions
$total = 1001;
$people = 5;
// count what is the minimal value, that all the results will have
$value = floor($total / $people);
$result = array_fill(0, $people, $value);
// distribute missing "+1"s as needed in the result
$overheads = $total - $value * $people;
for ($i = 0; $i < $overheads; $i++) {
$result[$i]++;
}
// voila...
var_dump($result);
So, the above script should loop out:
200
200
200
200
201
foreach ($result as $r) echo $r . "\n";?echostatement is what you need here.