Smarty: printing a specific array element without using a foreach loop

{foreach from=$myArray item=item}
    {$item.attribute}
{/foreach}

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

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

$myArray[2].attribute
+5
source share
3 answers

{$myArray[2].attribute}will be correct. Have you tried

+11
source

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

0
source

$ myArray [2] → this attribute works for me.

0
source

All Articles