Heim  >  Artikel  >  Backend-Entwicklung  >  thinkphp模板中判断volist循环的最后一条记录_PHP教程

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

WBOY
WBOYOriginal
2016-07-13 10:31:181425Durchsuche

用过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>

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

您可能感兴趣的文章

  • thinkphp打印最后一条sql语句
  • smarty模板中使用php函数以及smarty模板中如何对一个变量使用多个函数
  • smarty 模板中循环表格补充不全的td
  • smarty模板中判断数组为空的方法
  • Thinkphp 模板中常用的系统变量总结
  • thinkphp截取中文字符串的方法
  • smarty模板中for循环的扩展插件
  • ThinkPHP内置模板引擎的使用方法总结

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/764115.htmlTechArticle用过smarty做过php开发的朋友应该都知道在smarty模板里面判断foreach循环是否是最后一个可以用$smarty.foreach.name.last来判断循环是否到了最后一...
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn