3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $number = 28; $columnCount = 4; for($i = 1, $loopCounter = 1; $i <= $number; $i = $i + $columnCount, $loopCounter++) { $range = range($i, $i+$columnCount - 1); if($loopCounter % 2 === 0) { $range = array_reverse($range); } foreach($range as $n) { echo str_pad($n, 2, ' ', STR_PAD_LEFT) . " "; } echo "\n"; }