【发布时间】:2010-10-05 06:57:24
【问题描述】:
我有一个关联数组,我正在尝试使用 smarty 获取第一条记录。
在 php 中我使用 current(array),但 smarty 似乎没有 current。
所以我写了下面的代码
{if is_array($browseProducts.data) }
<ul class="products-grid">
{foreach from=$browseProducts.data item=item}
{assign var='image' value=''}
{if is_array($item.images) }
{php} $image=current($item.images); {/php}
{/if}
{/foreach}
</ul>
{/if}
在 {php} 部分 current($item.images) 给出警告:current() [function.current]: Passed variable is not an array or object
语法是正确的,所以我猜来自 smarty 的 $item.images 不能被 {php} 读取
将 $item.images 传递给 {php} 部分的任何方式,或者什么。
有什么建议可以解决我的问题吗?
【问题讨论】:
标签: smarty