Home  >  Article  >  Backend Development  >  ThinkPHP模板中判断volist循环的最后一条记录的验证方法_PHP

ThinkPHP模板中判断volist循环的最后一条记录的验证方法_PHP

WBOY
WBOYOriginal
2016-06-01 11:51:45807browse

ThinkPHP

对于用过smarty做过php开发的朋友来说,应该都知道在smarty模板里面判断foreach循环是否是最后一个可以用$smarty.foreach.name.last来判断循环是否到了最后一条记录,在thinkphp的模板中常见的循环是volist,但是volist的各种属性中并没有直接判断最后一条记录的属性,那么在thinkphp中如何判断呢?下面的代码可以实现ThinkPHP中volist断最后一条记录。
举例代码如下,读者可以自己去体会。


  • class="last">
  • 以上代码段中的$i是volist循环中的一个计数变量,默认名称就是$i,因此可以不用声明而直接使用。

    Statement:
    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