SMARTY的SECTION循环如何使用?

SMARTY的SECTION循环如何使用


慕仙森
浏览 871回答 3
3回答

湖上湖

$people = array('tony','sweety','abc','four');$smarty->assign('people',$people); {section name=n loop=$people}name:{$people[n]}<br/>{/section}效果:name:tonyname:sweetyname:abcname:four

PIPIONE

<!DOCTYPE&nbsp;HTML&nbsp;PUBLIC&nbsp;"-//W3C//DTD&nbsp;HTML&nbsp;4.0 Transitional//EN"><HTML><HEAD><TITLE> New Document </TITLE><META&nbsp;NAME="Generator"&nbsp;CONTENT="EditPlus"><META&nbsp;NAME="Author"&nbsp;CONTENT=""><META&nbsp;NAME="Keywords"&nbsp;CONTENT=""><META NAME="Description" CONTENT=""></HEAD><BODY>[#section name=$i loop=$arr#][#$arr[$i]#][#$br#][#/section#]</BODY></HTML>php部分:<?phpinclude_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');?>
打开App,查看更多内容
随时随地看视频慕课网APP