第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

smarty里面的section 怎樣遍歷關(guān)聯(lián)的多維數(shù)組?

smarty里面的section 怎樣遍歷關(guān)聯(lián)的多維數(shù)組?

GCT1015 2019-04-03 10:07:38
smarty里面的section 怎樣遍歷關(guān)聯(lián)的多維數(shù)組
查看完整描述

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



查看完整回答
反對(duì) 回復(fù) 2019-04-13
?
富國(guó)滬深

TA貢獻(xiàn)1790條經(jīng)驗(yàn) 獲得超9個(gè)贊

$smarty -> assign("newsreco",$newsreco);

"$newsreco"這里加上雙引號(hào)的話,值還沒有傳遞就直接被展開成Array了。

另外如果可以用foreach的時(shí)候,還是用foreach比較好,section的效率比foreach低很多,這不是一個(gè)喜歡與否的問題。

查看完整回答
反對(duì) 回復(fù) 2019-04-13
  • 3 回答
  • 0 關(guān)注
  • 874 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)