Advertisement
Guest User

Untitled

a guest
Apr 28th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.54 KB | None | 0 0
  1. <table width="100%" border=1>
  2.   <tr>
  3.     <?php
  4.     $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12);
  5.  
  6.     $count = 0;
  7.     $bilderProReihe = 5;
  8.     foreach($array as $element) { // oder while
  9.       if($count < $bilderProReihe) {
  10.         $count++;
  11.       } else {
  12.         echo '</tr><tr>';
  13.         $count = 1;
  14.       }
  15.       echo '<td width="'.(100 / $bilderProReihe).'%">'.$element.'</td>';
  16.     }
  17.     $remainingCells = $bilderProReihe - $count;
  18.     echo '<td colspan="'.$remainingCells.'">&nbsp;</td>';
  19.     ?>
  20.   </tr>
  21. </table>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement