9.Smarty的循环

1.session循环

目的:循环输出一个二维数组

构造一个二维数组

$towSide = array(
    array("name"=>"caimuqing","sex"=>"boy"),
    array("name"=>"caiyitao","sex"=>"girl")
);
$smarty->assign('towSide',$towSide);

调用session循环输出

{section name=people loop=$towSide}
    {$towSide[people].name}
    {$towSide[people].sex}
    <br/>
{/section}

结果:

 session循环除了name和loop,还有start step max show

2.使用foreach循环

{foreach $towSide as $people}
    {$people.name}
    {$people.sex}
{foreachelse}
    no peoples
{/foreach}

 

posted @ 2016-07-19 17:29  笨蛋敏  阅读(358)  评论(0编辑  收藏  举报