Canman2005 Posted May 2, 2010 Share Posted May 2, 2010 Hi all I have the following code <?php $array = array(1,2,3,4,5,6,7,8,9,10,11,12,13); $cols = 3; $count = count($array); if($count%$cols > 0){ for($i=0;$i<($cols-$count%$cols);$i++){ $array[] = ' '; } } echo "<table border=\"1\">\r\n"; foreach($array as $key => $td){ if($key%$cols == 0) echo "<tr>\r\n"; echo "<td>$td</td>\r\n"; if($key%$cols == ($cols - 1)) echo "</tr>\r\n"; } echo "</table>"; ?> which works great and returns something like 1 2 3 4 5 6 7 8 9 10 11 12 13 but is it possible to change this so that it orders the results like 1 5 9 13 2 6 10 3 7 11 4 8 12 any help would be great Thanks Quote Link to comment Share on other sites More sharing options...
shortj75 Posted May 3, 2010 Share Posted May 3, 2010 did you try changeing this echo "<td>$td</td>\r\n"; to echo "<tr><td>$td</td></tr>\r\n"; this should be close to what your looking for Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.