问题
I want to get last element of array in smarty template without using loop
<?php
$arr = array("first","second","third");
$smarty->assign("arr",$arr);
回答1:
There is an easy way to get this done within your Smarty template code using a variable modifier:
{$arr|@end}
Since all php-functions can be used as modifiers , end will do the job just fine.
来源:https://stackoverflow.com/questions/36889268/how-to-get-last-element-of-an-array-in-smarty-templates