Home >Backend Development >PHP Tutorial >Verification method to determine the last record of volist loop in ThinkPHP template_PHP tutorial

Verification method to determine the last record of volist loop in ThinkPHP template_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:26:251066browse

For those who have used smarty to do PHP development, they 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. A common loop in thinkphp templates is volist, but the various attributes of volist do not directly determine the attributes of the last record, so how to determine it in thinkphp? The following code can implement volist breaking of the last record in ThinkPHP.
The example code is as follows, readers can experience it themselves.

<volist name='lists' id='list'>
<li <if condition="$i eq count($lists)">class="last"</if>>
<a href="http://www.jb51.net/">脚本之家</a>
</li>
</volist>

$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.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/824687.htmlTechArticleFor those who have used smarty to do PHP development, they should all know whether to judge whether the foreach loop is in the smarty template It is the last one. You can use $smarty.foreach.name.last to determine whether the loop...
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