How to get last element of an array in smarty templates

廉价感情. 提交于 2020-03-22 10:22:54

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!