Guest User

Untitled

a guest
Jun 18th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. <?php
  2. $data = array(); // assume this has stuff and has 12 elements
  3.  
  4. $itemsPerRow = 7;
  5.  
  6.  
  7. $totalRows = ciel($data / $itemsPerRow); // ~1.714 -> 2
  8.  
  9. $currentRow = 1;
  10.  
  11. for($i = 0; $i < $totalRows; $i++) {
  12.  
  13.  
  14. if($i < count($data)) {
  15. $item = $data[$i];
  16. // print <td>$item</td>
  17. } else {
  18. // print <td></td>
  19. }
  20.  
  21. if(($i % $itemsPerRow) == 0) {
  22. // print new table row
  23. $currentRow++;
  24. }
  25. }
Add Comment
Please, Sign In to add comment