如何在 smarty 模板中获取数组的最后一个元素
How to get last element of an array in smarty templates
我想在不使用循环的情况下获取 smarty 模板中数组的最后一个元素
<?php
$arr = array("first","second","third");
$smarty->assign("arr",$arr);
有一种简单的方法可以在您的 Smarty 模板代码中使用 variable modifier:
{$arr|@end}
因为所有 php 函数都可以用作修饰符,所以 end
可以很好地完成这项工作。
我想在不使用循环的情况下获取 smarty 模板中数组的最后一个元素
<?php
$arr = array("first","second","third");
$smarty->assign("arr",$arr);
有一种简单的方法可以在您的 Smarty 模板代码中使用 variable modifier:
{$arr|@end}
因为所有 php 函数都可以用作修饰符,所以 end
可以很好地完成这项工作。