[英]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? 而不是打印数组的每个元素的所有属性,我想只使用foreach循环输出第3个元素,是否可能?
I'm looking for something like the below, but I don't know the syntax: 我正在寻找类似下面的内容,但我不知道语法:
$myArray[2].attribute
{$myArray[2].attribute}
would be correct. {$myArray[2].attribute}
是正确的。 Did you try it? 你试过吗?
$ myArray [2] - >属性这个适合我。
使用{$myArray.2.attribute}
获取属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.