Home > Backend Development > PHP Tutorial > Determine the last record of volist loop in thinkphp template_PHP tutorial

Determine the last record of volist loop in thinkphp template_PHP tutorial

WBOY
Release: 2016-07-13 10:31:18
Original
1578 people have browsed it

Friends who have used smarty to do PHP development should all know that in the smarty template to determine whether the foreach loop is the last one, you can use $smarty.foreach.name.last to determine whether the loop has reached the last record. In thinkphp How to judge? A common loop in thinkphp templates is volist, and the various attributes of volist do not directly judge this. Here is how to judge the last record in thinkphp volist.

The example code is as follows, feel it for yourself.

<volist name='lists' id='list'>
<li <if condition="$i eq count($lists)">class="last"</if>>
<a href="http://www.phpernote.com/tag/thinkphp">thinkphp教程</a>
</li>
</volist>
Copy after login

$i in the above code snippet is a count variable in the volist loop. The default name is $i, so it can be used directly without declaration.

Articles you may be interested in

  • thinkphp prints the last sql statement
  • Using php functions in smarty templates and how to use multiple variables for one variable in smarty templates Function
  • The loop table in the smarty template is incompletely supplemented with td
  • The method to determine if the array is empty in the smarty template
  • Summary of commonly used system variables in Thinkphp templates
  • How thinkphp intercepts Chinese strings
  • Extension plug-in for for loop in smarty template
  • Summary of how to use ThinkPHP’s built-in template engine

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/764115.htmlTechArticleFriends who have used smarty to do PHP development should all know that it is possible to determine whether the foreach loop is the last one in the smarty template. Use $smarty.foreach.name.last to determine whether the loop has reached the last one...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template