For Loop

1 view
Skip to first unread message

Sydore

unread,
Dec 11, 2012, 1:07:19 PM12/11/12
to pai...@googlegroups.com
Hi All,

I want to code something which similar the below php code

$i=0;
@articles.each do | category |

if($i==0) { // do something, set a class id or div element }
if($i==3) { $i=0; } else { $i++; }

end

Not sure if you understand my question.

Best Regards,
Sydore Pry

Samnang Chhun

unread,
Dec 11, 2012, 8:31:25 PM12/11/12
to pai...@googlegroups.com
I see code example above is ruby code, but you said it is php?

Please give more detail or example in input and output that you expected.

Thanks,
Samnang




--
You received this message because you are subscribed to the Google Groups "Pailin (Cambodia Ruby/RubyOnRails User Group)" group.
To post to this group, send email to pai...@googlegroups.com.
To unsubscribe from this group, send email to pailin+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/pailin/-/JE2xZu-Z88UJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
H.P (+855)16 701 721

Website:  http://wowkhmer.com
Twitter:    http://twitter.com/samnangchhun

kuyseng chhoeun

unread,
Dec 11, 2012, 9:18:14 PM12/11/12
to pai...@googlegroups.com
As I read, I may confuse or not, he want to write his below code in php code. 
Just my idea, but I'm not sure to answer the question.

Thanks;
kuyseng

pry sydorei

unread,
Dec 11, 2012, 9:22:00 PM12/11/12
to pai...@googlegroups.com
I am sorry to confuse you, but some kind of I want is :

i = 0


@articles.each do | category |

  i += 1
  if i == 3 then
    // do last record in the row
  end


end
Reply all
Reply to author
Forward
0 new messages