开发者

Smarty: print a specific element of an array WITHOUT using foreach loop

{foreach from=$myArray item开发者_高级运维=item}
    {$item.attribute}
{/foreach}

instead of printing all attributes of each element of the array, I want to output only the 3rd element WITHOUT using a foreach loop, is it possible?

I'm looking for something like the below, but I don't know the syntax:

$myArray[2].attribute


{$myArray[2].attribute} would be correct. Did you try it?


Use {$myArray.2.attribute} to get the attribute.


$myArray[2]->attribute this one works for me.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜