3 回答

largeQ
TA貢獻(xiàn)2039條經(jīng)驗(yàn) 獲得超8個(gè)贊
1 $arr
= array(
2
array('id'=>1,'title'=>'title1'),
3
array('id'=>2,'title'=>'title2'),
4
array('id'=>3,'title'=>'title3')
5 );
6
7
$smarty->assign('news',$arr);
1 {section name=sn loop=$news}
2 {if $smarty.section.sn.first}
3
<table>
4
<th>id</th>
5
<th>title</th>
6 {/if}
7
<tr>
8
<td>{$news[sn].id}</td>
9
<td>{$news[sn].title}</td>
10
</tr>
11 {if $smarty.section.sn.last}
12
</table>
13 {/if}
14 {sectionelse}
15 there is no news.
16 {/section}
顯示結(jié)果如下(是一個(gè)表格的樣子,以下顯示的沒有加樣式):
1 id title
2 1 title1
3 2 title2
4 3 title3
- 3 回答
- 0 關(guān)注
- 874 瀏覽
添加回答
舉報(bào)
0/150
提交
取消