Anyone who has used smarty for php development should know whether the foreach loop in the smarty template can use $ smarty. foreach. name. last to determine whether the loop has reached the last record. How can we determine in thinkphp? In thinkphp templates, the common cycle is volist, And the volist attributes do not directly judge this. The following describes how to judge the last record in thinkphp volist.
The sample code is as follows.
<Volist name = 'lists' id = 'LIST'> <li <if condition = "$ I eq count ($ lists) "> class =" last "</if> <a href =" http://www.phpernote.com/tag/thinkphp "> thinkphp tutorial </a> </li> </volist>
$ I in the above code snippet is a counting variable in the volist loop. The default name is $ I, so you can directly use it without declaration.
Articles you may be interested in
- Thinkphp prints the last SQL statement
- Use php functions in the smarty template and how to use multiple functions for a variable in the smarty Template
- The cycle table in the smarty template contains incomplete td
- Method for judging null array in the smarty Template
- Summary of common system variables in Thinkphp templates
- Thinkphp intercepts Chinese strings
- Extension of the for loop in the smarty Template
- ThinkPHP built-in template engine usage Summary