I have an associative array and I'm trying to get the first record with smarty.
In php, I use current (array), but smarty dont seems to have current.
So I wrote the code below
{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}
in the field {php} current ($ item.images) gives a warning: current () [function.current]: the passed variable is not an array or object
The syntax is right, so I think smarty's $ item.images cannot be read {php}
Any way to pass $ item.images to the {php} section or whatever.
Any suggestion to solve my problem?
source
share