Home > php教程 > php手册 > thinkphp模板中判断volist循环的最后一条记录

thinkphp模板中判断volist循环的最后一条记录

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 09:36:37
Original
1024 people have browsed it

用过smarty做过php开发的朋友应该都知道在smarty模板里面判断foreach循环是否是最后一个可以用$smarty.foreach.name.last来判断循环是否到了最后一条记录,在thinkphp中如何判断呢?在thinkphp的模板中常见的循环是volist,而volist的各种属性中并没有直接判断这个的,下面就说下在thinkphp volist中是如何判断最后一条记录的。

举例代码如下,意思自己去体会吧。

<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是volist循环中的一个计数变量,默认名称就是$i,因此可以不用声明直接使用。

您可能感兴趣的文章

  • thinkphp打印最后一条sql语句
  • smarty模板中使用php函数以及smarty模板中如何对一个变量使用多个函数
  • smarty 模板中循环表格补充不全的td
  • smarty模板中判断数组为空的方法
  • Thinkphp 模板中常用的系统变量总结
  • thinkphp截取中文字符串的方法
  • smarty模板中for循环的扩展插件
  • ThinkPHP内置模板引擎的使用方法总结
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
Latest Issues
Why thinkphp has better performance than laravel?
From 1970-01-01 08:00:00
0
0
0
ThinkPHP Why use composer?
From 1970-01-01 08:00:00
0
0
0
thinkphp versions supported by php6
From 1970-01-01 08:00:00
0
0
0
thinkphp upload files
From 1970-01-01 08:00:00
0
0
0
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template