Smarty foreach control cycle

Recommended for you: Get network issues from WhatsUp Gold. Not end users.

1 in the   smarty  array is often used, loop through the array by using   section  or   foreach , how to get the length of the array or to judge an array a number? You can use {$array|  count}  to try.


{foreach from=$variable key=key name=name iteam=value}

    {$variable|@count}     // Gets the length of the array

        {$smarty.foreach.loop.index}        //  the circular array element subscript, At 0.

        {$smarty.foreach.loop.iteration}        //  access to the current number of cycles, At 1.

        {$smarty.foreach.loop.first}        //  true, Mark cycle is executed for the first time

        {$smarty.foreach.loop.last}        //  true, Mark cycle last execution
  {$}        //  true, Mark cycle last execution

        {$}        //  whether the current display

        {$}        //  cycle number


 3,Control cycle

{foreach name=infolist from=$VIDEO_INFO_LIST item=infolist}
{assign var=floor value=$smarty.foreach.infolist.index}
{if $floor<5%}     
 {* or if $smarty.foreach.infolist.iteration <5*}

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Oliver at October 27, 2013 - 10:24 PM