Home >Backend Development >PHP Tutorial >Verification method to determine the last record of volist loop in ThinkPHP template_PHP tutorial
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.