smarty里SECTION如何循环一个值?

smarty里SECTION如何循环一个值?


江户川乱折腾
浏览 658回答 5
5回答

qq_笑_17

{section name=loop loop=$count}id: {$loop}{/section} 给count赋个值$smarty->assign(\'count\', 5);用一段section模拟:{section name=loop loop=$count}id: {$smarty.section.loop.index}{/section}

富国沪深

<tr>{section name="list" loop="$newslist"}<td>{$newslist[list].title}</td><!--index 从0开始记 具体含义参考smarty手册-->{if $smarty.section.list.index eq 4}</tr><tr>{/if}{/section}</tr>

白衣染霜花

实践是验证真理的唯一标准,多动手敲代码做试验:打印结果:结论:当有多层嵌套循环时,break语句只结束当前层的循环。

largeQ

foreach 没有跳出的这个如果有这种需求,建议使用{section},{sectionelse}max integer No 1 设定循环最大执行次数.
打开App,查看更多内容
随时随地看视频慕课网APP