(1)一維數組web
可使用foreach.數組
好比:oop
數組:$addr = array(
'01' => '廣州',
'02' => '韶關', 狗蛋大智慧2011版下載spa
'03' => '深圳',
'04' => '珠海',
'05' => '汕頭',
'06' => '佛山',
'53' => '雲浮',
'52' => '揭陽',
'51' => '潮州',
'20' => '中山',
'19' => '東莞',
'07' => '江門',
'08' => '湛江',
'09' => '茂名',
'12' => '肇慶',
'13' => '惠州',
'14' => '梅州',
'15' => '汕尾',
'16' => '河源',
'17' => '陽江',
'18' => '清遠'
);blog
能夠經過get
<!--{foreach from=$addr item=addre}-->
<option value="<!--{$addre}-->"><!--{$addre}--></option>
<!--{/foreach}-->it
輸出io
PS.foreach
若是是$array = array('value1','value2');這種形式的數組,也能夠經過下載
{section name=id loop=$array}
{$array[id]}
{/section}
輸出
(2)二維數組:
可能經過section 或 foreach
section 的用法以下:
$webs = array(
0 => array(
name => '牧羊城',
addr => 'http://www.muyangcheng.com'
),
1 => array(
name => '廣州論壇',
addr => 'http://www.muyangcheng.com'
)
);
<!--{section name=usr loop=$webs}--> <a href="<!--{$webs[usr].addr}-->"><!--{$webs[usr].name}--></a> <!--{/section}-->