Michan Posted December 9, 2007 Share Posted December 9, 2007 Hi all, Say I have an array of ten results; how would I output the first five and no more? Thanks in advance. - Mi Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted December 9, 2007 Share Posted December 9, 2007 Kinda depends on the array. Assuming an array with keys 0,1,2,3,4,5 etc: for($i=0;$i<5;$i++){ echo $array[$i].'<br />'; } If you have other keys, you could try: $i=0; foreach($array as $v){ echo $v.'<br />'; if(++$i==5){ break; } } Quote Link to comment Share on other sites More sharing options...
Michan Posted December 9, 2007 Author Share Posted December 9, 2007 Thanks, the second snippet works very well! So how would I output results #6 - 10? Thank you in advance Quote Link to comment Share on other sites More sharing options...
Michan Posted December 9, 2007 Author Share Posted December 9, 2007 Hate to bump, but.. anyone? 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.