dennismonsewicz Posted September 2, 2010 Share Posted September 2, 2010 I am trying to create a script that will show a block of images for every nine items in an array. So it doesn't need to show the block of images for every 9 items, but every time the counter hits 9 show a block of images. Make sense? I am stumped as all get out. Thanks for all the help in advance! Quote Link to comment https://forums.phpfreaks.com/topic/212368-showing-blocks-of-elements-using-for-loop/ Share on other sites More sharing options...
MiCR0 Posted September 2, 2010 Share Posted September 2, 2010 Post all your code, No not fully understand what your doing. Quote Link to comment https://forums.phpfreaks.com/topic/212368-showing-blocks-of-elements-using-for-loop/#findComment-1106490 Share on other sites More sharing options...
litebearer Posted September 2, 2010 Share Posted September 2, 2010 if array count = 9, do this, else do that OR if the count may be greater than 9 use modulus Quote Link to comment https://forums.phpfreaks.com/topic/212368-showing-blocks-of-elements-using-for-loop/#findComment-1106491 Share on other sites More sharing options...
JonnoTheDev Posted September 2, 2010 Share Posted September 2, 2010 Really simple <?php // array containg 100 elements $x = range(1,100); $counter = 1; foreach($x as $item) { print $counter."<br />"; if($counter == 9) { // display images print "displaying images<br />"; $counter = 1; } else { $counter++; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/212368-showing-blocks-of-elements-using-for-loop/#findComment-1106493 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.