聪明的部分循环

seo*_*ppc 7 php smarty

我试图得到一个循环跟随...

{$product.min_val} //2
{$product.max_val} //8
Run Code Online (Sandbox Code Playgroud)

而我正在努力追随......

{section name=val start=$product.min_val loop=$product.max_val step=0}
<p id="{$smarty.section.val.index}">{$smarty.section.val.index}</p>
{/section}
Run Code Online (Sandbox Code Playgroud)

它打印以下......

<p id="2">2</p>
<p id="3">3</p>
<p id="4">4</p>
<p id="5">5</p>
<p id="6">6</p>
<p id="7">7</p>
Run Code Online (Sandbox Code Playgroud)

您可能已经注意到,它缺少<p id="8">8</p>根据{$product.max_val} 的感谢.

xpa*_*pad 8

循环是该部分循环的次数,因此您需要:

{section name=val start=$product.min_val loop=$product.max_val+1}
<p id="{$smarty.section.val.index}">{$smarty.section.val.index}</p>
{/section}
Run Code Online (Sandbox Code Playgroud)