开发者

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

开发者 https://www.devze.com 2023-02-06 20:10 出处:网络
{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 f
{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

精彩评论

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