Friday, October 1, 2010

Re: Help with foreach

I'm not sure I completely understand your problem but why not use for
instead. that way you can increment for how much you want.

On Oct 1, 7:23 am, "Dave Maharaj" <m...@davemaharaj.com> wrote:
> 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?

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: