1,smarty foreach
1,单纯的数组array(1000,2000,3000),使用foreach(from = $array item=foo){$foo}
2,键值对数组
<ul>
{foreach from=$myArray key=k item=v}
<li>{$k}: {$v}</li>
{/foreach}
</ul>
3,键值对数组
<ul>
{foreach from=$items key=myId item=i}
<li><a href="item.php?id={$myId}">{$i.no}: {$i.label}</li>
{/foreach}
</ul>
或者{foreach $items as $i}
时间: 2024-10-22 08:07:21