slaterino Posted January 4, 2016 Share Posted January 4, 2016 I am currently using a simple array with a grid layout that outputs from Wordpress, which allows me to specify the three columns of the grid. Now, I am wanting to add something hard-coded into the third column of the first row. Which essentially means that my array would need to go 'first,second' for the first row (then I will add my hard-coded item in the third column) and then 'first,second,third' infinitely after that. Is there any way that this is possible to implement practically, so that the array just goes 'first' and 'second' and then switches to the 'first','second,'third' array? Here's the current code that I'm using: $style_classes = array('first','second','third'); $styles_count = count($style_classes); $style_index = 0; <div class="grid_5 <?php $k = $style_index % $styles_count; echo "$style_classes[$k]"; $style_index++; ?>"> Quote Link to comment Share on other sites More sharing options...
Muddy_Funster Posted January 4, 2016 Share Posted January 4, 2016 All you need is a basic counter in the loop (although you seem to not have included said loop in your code...) combined with an if conditional check to specify an output dependant on the state of the counter. 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.