TheNix Posted March 5, 2009 Share Posted March 5, 2009 I know to print an array i can do foreach($names as $value){ echo $value; } But what if I just want to print the 10, then break and print the next 10, till i run out? Quote Link to comment Share on other sites More sharing options...
genericnumber1 Posted March 5, 2009 Share Posted March 5, 2009 I'm not sure what you mean, why would you want to print 10, break and then print 10 when you could just print 20 to begin with? Quote Link to comment Share on other sites More sharing options...
TheNix Posted March 5, 2009 Author Share Posted March 5, 2009 Well I have an array of names that have been randomized and I want to place a number of them, up to 10 at a table then place the same at the next table and so on till I'm out of people. I was just trying to make a simple example. Quote Link to comment Share on other sites More sharing options...
Psycho Posted March 5, 2009 Share Posted March 5, 2009 It would be much easier if you gave an exampe of the code you want to use to display these in. You say you wnat 10 names in each table, but did you mean 10 names in each row of a table? Anyway here is a quick example of how to do it with separate tables (not tested): <?php $count = 1; foreach ($names as $name) { if ($count==1) { echo "<table><tr>"; } echo "<td>$name</td>"; $count++; if ($count>10) { echo "</tr></table>"; $count = 1; } } if ($count!=1) { echo "</tr></table>"; } ?> Quote Link to comment Share on other sites More sharing options...
TheNix Posted March 5, 2009 Author Share Posted March 5, 2009 Thank you very much 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.