Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $data = array(); // assume this has stuff and has 12 elements
- $itemsPerRow = 7;
- $totalRows = ciel($data / $itemsPerRow); // ~1.714 -> 2
- $currentRow = 1;
- for($i = 0; $i < $totalRows; $i++) {
- if($i < count($data)) {
- $item = $data[$i];
- // print <td>$item</td>
- } else {
- // print <td></td>
- }
- if(($i % $itemsPerRow) == 0) {
- // print new table row
- $currentRow++;
- }
- }
Add Comment
Please, Sign In to add comment