1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to break from <xen:foreach>

Discussion in 'XenForo Development Discussions' started by Syndol, Sep 23, 2011.

  1. Syndol

    Syndol Guest

    Is there a way to break from a <xen:foreach> loop in a template?
  2. Kier

    Kier XenForo Developer Staff Member

    There's no break, but you can iterate for a specific count like this:
    <xen:foreach loop="$array" key="$key" value="$value" i="$i">
    	<xen:if is="{$i} <= 10">
    moby2006, cclaerhout and Onimua like this.
  3. Syndol

    Syndol Guest

    Thank you Kier.
  4. xfrocks

    xfrocks Well-Known Member

    TIL <xen:foreach> supports "i"!!!! I have to fix my array_values calls now. Thanks Kier!
  5. Hoffi

    Hoffi Well-Known Member

    You're a good software developer, if you did can program without using break. ;) (Except in switch/case!)

Share This Page