Smarty - foreach loop 10 times and stop

后端 未结 8 2416
执念已碎
执念已碎 2021-02-07 12:31

Im using the following Smarty code:

{foreach from=$entries key=i item=topic}
  {if $topic.topic_style == question}
    
  • 8条回答
    •  不要未来只要你来
      2021-02-07 12:48

      All the above worked to a certain degree, but not exactly what I wanted. Here's what worked for me. I basically used the index property of foreach

      {foreach $products as $product}
      {if $product@index eq 3}
          {break}
      {/if}
      
      

      {/foreach}

    提交回复
    热议问题