3 回答
TA贡献2003条经验 获得超2个赞
$people = array('tony','sweety','abc','four');
$smarty->assign('people',$people); {section name=n loop=$people}
name:{$people[n]}<br/>
{/section}效果:name:tony
name:sweety
name:abc
name:four
TA贡献1829条经验 获得超9个赞
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>
<BODY>
[#section name=$i loop=$arr#]
[#$arr[$i]#]
[#$br#]
[#/section#]
</BODY>
</HTML>
php部分:
<?php
include_once('./smarty/Smarty.class.php');
$tpl = new Smarty();
$br="<br/>";
for($i=0;$i<10;$i++){
$arr[$i+1]='你好';
}
$tpl->assign('arr',$arr);
$tpl->assign('i',$i);
$tpl->assign('br',$br);
$tpl->display('section.tpl');
?>
- 3 回答
- 0 关注
- 870 浏览
添加回答
举报