1. You can use {$ array | count} to try it.
2.
Copy codeCode: {foreach from = $ variable key = key name = name iteam = value}
{$ Variable | @ count} // obtain the array Length
{$ Smarty. foreach. loop. index} // gets the element subscript of the current loop array, starting with 0
{$ Smarty. foreach. loop. iteration} // gets the number of current cycles, starting with 1
{$ Smarty. foreach. loop. first} // if it is true, mark the first execution of the loop
{$ Smarty. foreach. loop. last} // if it is true, mark the last execution of the loop
{$ Smarty. foreach. name. last} // if it is true, mark the last execution of the loop
{$ Smarty. foreach. loop. show} // whether the current display is displayed
{$ Smarty. foreach. loop. total} // number of cycles
{/Foreach}
3. Control the number of cycles
Copy codeThe Code is as follows: {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 *}
<Li >{$ infolist %} </li>
{/If}
{/Foreach}