- 1、本文档共5页,可阅读全部内容。
- 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
这篇文章主要介绍了 smarty 循环嵌套用法 ,结合实例形式分析了 Smarty 模板嵌套循环的
实现技巧与相关注意事项 ,需要的朋友可以参考下
test3.php:
lt;?php
require main.php;
$forum = array(
nbsp; nbsp; array(category_id =gt; 1, category_name =gt; 公告区 ,
nbsp; nbsp; nbsp; topic =gt; array(
nbsp; nbsp; nbsp; nbsp; array(topic_id =gt; 1, topic_name =gt; 站务公告 )
nbsp; nbsp; nbsp; )
nbsp; nbsp; ),
nbsp; nbsp; array(category_id =gt; 2, category_name =gt; 文学专区 ,
nbsp; nbsp; nbsp; topic =gt; array(
nbsp; nbsp; nbsp; nbsp; array(topic_id =gt; 2, topic_name =gt; 好书介绍 ),
nbsp; nbsp; nbsp; nbsp; array(topic_id =gt; 3, topic_name =gt; 奇文共赏 )
nbsp; nbsp; nbsp; )
nbsp; nbsp; ),
nbsp; nbsp; array(category_id =gt; 3, category_name =gt; 电脑专区 ,
nbsp; nbsp; nbsp; topic =gt; array(
nbsp; nbsp; nbsp; nbsp; array(topic_id =gt; 4, topic_name =gt; 硬件周边 ),
nbsp; nbsp; nbsp; nbsp; array(topic_id =gt; 5, topic_name =gt; 软件讨论 )
nbsp; nbsp; nbsp; )
nbsp; nbsp; )
);
$tpl-gt;assign(forum, $forum);
$tpl-gt;display(test3.htm);
?gt;
样版的写法如下:
templates/test3.htm:
lt;htmlgt;
lt;headgt;
lt;titlegt; 循环嵌套测试 lt;/titlegt;
lt;/headgt;
lt;bodygt;
lt;table width=200 border=0 align=center cellpadding=3 cellspacing=0gt;
nbsp; lt;{section name=sec1 loop=$forum}gt;
nbsp; lt;trgt;
nbsp; nbsp; lt;td colspan=2gt;lt;{$forum[sec1].category_name}gt;lt;/tdgt;
nbsp; lt;/trgt;
nbsp; lt;{section name=sec2 loop=$forum[sec1].topic}gt;
nbsp; lt;trgt;
nbsp; nbsp; lt;td width=25gt; lt;/tdgt;
nbsp; nbsp; lt;td
w
文档评论(0)