Jump to content

Creating A Slightly Unusual Array


slaterino

Recommended Posts

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++; ?>">

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.