How to break from <xen:foreach>

  • Thread starter Thread starter Syndol
  • Start date Start date
S

Syndol

Guest
Is there a way to break from a <xen:foreach> loop in a template?
 
There's no break, but you can iterate for a specific count like this:
Code:
<xen:foreach loop="$array" key="$key" value="$value" i="$i">
<xen:if is="{$i} <= 10">
<div>{$value}</div>
</xen:if>
</xen:foreach>
TIL <xen:foreach> supports "i"!!!! I have to fix my array_values calls now. Thanks Kier!
 
You're a good software developer, if you did can program without using break. ;) (Except in switch/case!)
 
Top Bottom