t_machine Posted September 2, 2007 Share Posted September 2, 2007 hi, I am wondering if anyone could help me solve this issue. I am using a foreach loop and i would like to add a line break after three records then repeat the process. Example: foreach($array as $v){ echo $v.' '; } In that example, it will display ( apples oranges banana pumpkin turnips pineapple beer pepsi) How do i get it to display: apples oranges banana pumpkin turnips pineapple beer pepsi etc.... Notice above that after each three results the next three are placed on a new line. How can I accomplish that with my loop. Thanks very much for any help Quote Link to comment https://forums.phpfreaks.com/topic/67589-solved-how-to-add-a-after-3-results/ Share on other sites More sharing options...
Fadion Posted September 2, 2007 Share Posted September 2, 2007 $count = 1; foreach($array as $v){ echo $v.' '; if($count%3 == 0){ echo '<br />'; } } Quote Link to comment https://forums.phpfreaks.com/topic/67589-solved-how-to-add-a-after-3-results/#findComment-339531 Share on other sites More sharing options...
t_machine Posted September 2, 2007 Author Share Posted September 2, 2007 Thank you very much. It works perfectly now Quote Link to comment https://forums.phpfreaks.com/topic/67589-solved-how-to-add-a-after-3-results/#findComment-339536 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.