Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>Dynamic Column</title>
- </head>
- <body>
- <table border="1">
- <tr>
- <?php
- $data=array('satu','dua','tiga','empat','lima','enam','tujuh','delapan');
- $jml_data=count($data);
- $jml_kolom=4;
- $sisa=$jml_data%$jml_kolom;
- $i=0;
- while($jml_data)
- {
- echo ($i%$jml_kolom==0&&$i!=0?"</tr><tr>":"")."<td>{$data[$i]}</td>";
- $i++;
- $jml_data--;
- }
- if($sisa)
- for($i=1;$i<$sisa;$i++)
- echo "<td> </td>";
- ?>
- </tr>
- </table>
- </body>
- </htmL>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement