mkosmosports Posted January 9, 2007 Share Posted January 9, 2007 Hey,I have this line of code here which outputs all of the months covered in a given year. foreach ($transferdate as $trdate) { if (substr("$trdate",0,4) == "$season") { $trmon = substr("$trdate",4); echo("<div class=\"transfermon\"><a href=\"players.html?view=transfers&season=$season&in=$trmon\" alt=\"\">$trmon/$season</a></div>"); } }This works perfectly, theres just one thing that I cant seem to figure out. I want php to insert a <br> tag as soon as there is a fifth </div> tag present in the loop results.Any help appreciated... Quote Link to comment Share on other sites More sharing options...
effigy Posted January 9, 2007 Share Posted January 9, 2007 Set up a counter and use [url=http://us3.php.net/manual/en/language.operators.arithmetic.php]modulus[/url].[code]if ($counter % 5 == 0) { echo '---'; }[/code] Quote Link to comment Share on other sites More sharing options...
emehrkay Posted January 9, 2007 Share Posted January 9, 2007 place this before the loop$count = 0;then inside the loop do this[code]<?phpif (substr("$trdate",0,4) == "$season"){$break = (++$count % 5) ? '<br />' : ""$trmon = substr("$trdate",4); echo("<div class=\"transfermon\"><a href=\"players.html?view=transfers&season=$season&in=$trmon\" alt=\"\">$trmon/$season[/url]</div>".$break);?>[/code][/code] 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.