Thursday, September 30, 2010

Help with foreach

I have my find(‘list’) which gives me my standard array (ordered alphabetically)

 

(

                [16] => apples

                [24] => bananas

                [11] => cars        

[8] => zoo

….

…..

and so on

 

)

 

Now this is where I cant get it the way I need. They become selects in a form so I need them layed out 3 across each row

 

Label  [input]    |     Label  [input]         |     Label  [input]   

 

Next row…..

 

I found a lot of 3 per rows examples online but the problem comes in with adding the foreach ($listItems as $key => $value).

$i = 0;

Sure count the $listitems

$i%$row_count == 0 and build my rows but $i is only adding 1 each time…how do I get key [16] where $i = 0, [24] for 2 and so on….(I need the keys unchanged, I cnnot use 0,1,2,3 as the keys)

 

Any ideas?

 

No comments: