Is there any more professional or easier way to achieve a PHP for loop, that also iterates when there are only remaining elements? (In the current example: 1126)
<?php
$max = 11126;
$step = 2000;
for ($i = 0; $i < $max; null) {
if ($max - $i > $step) {
$i += $step;
} else {
$i += $max - $i;
}
echo($i . ", ");
}
?>
Outpts:
2000, 4000, 6000, 8000, 10000, 11126,
...which is correct, but looks like too much of code.