Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $data = [1,2,3,4,5,6,7,8,9,10,11,12,13];
- $columnWidth = 3;
- $minRows = 4;
- $offset = -$columnWidth;
- $rowOffset = 0;
- while($offset < count($data) - $columnWidth || $rowOffset < $minRows) {
- $cols = array_values(array_slice($data, $offset += $columnWidth, $columnWidth))
- + array_fill(0, $columnWidth, ' ');
- if($rowOffset === $minRows) {
- echo PHP_EOL;
- $rowOffset = 0;
- }
- echo '|', join('|', $cols), '|', PHP_EOL;
- $rowOffset++;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement