Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

php

smarty

{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
like image 290
evilReiko Avatar asked Jan 25 '11 10:01

evilReiko


1 Answers

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

like image 149
karim79 Avatar answered Sep 23 '22 18:09

karim79