Smarty显示数组值

时间:2012-02-22 19:56:03

标签: foreach smarty

我想在Smarty中显示以下数组:

->value = Array (2)
 0 => Array (1)
 0 => Array (4)
  SiteName => "USA"
  SanctionID => "41470"
  Program => "Men"
  Amount => "5.00"
 1 => Array (1)
  0 => Array (4)
  SiteName => "USA"
  SanctionID => "41471"
  Program => "Men"
  Amount => "5.00"

我正在使用两个foreach循环,但无法显示值。感谢任何帮助。

{foreach from=$SXid item=Amount key=SiteName}
    {foreach from=$SXid[sxid] item=Amount key=SiteName}
        <tr>
            <td></td>
            <td>{$Amount} is {$SiteName}</td>
            <td></td>
        </tr>
    {/foreach}
{/foreach}

1 个答案:

答案 0 :(得分:1)

{foreach from=$SXid item="outer" key="outer"}
    {foreach from=$outer item="value" key="key"}
        <tr>
            <td></td>
            <td>{$key|escape} =&gt; {$value|escape}</td>
            <td></td>
        </tr>
    {/foreach}
{/foreach}