Home >Backend Development >PHP Tutorial >Usage of smarty built-in function section, smarty built-in section_PHP tutorial

Usage of smarty built-in function section, smarty built-in section_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:09:15929browse

Usage of smarty built-in function section, smarty built-in section

The example in this article describes the usage of smarty’s built-in function section. Share it with everyone for your reference. The specific analysis is as follows:

The foreach function can do everything that section can do, so foreach is generally used. Here we also explain the usage of section in detail. Section can only traverse index arrays, not associative arrays.

Example of outputting array key values ​​in reverse order:

Template file: temp.htm

Copy code The code is as follows:
{section name=foo loop=$name step=-1}
{$name[foo]}
{/section}

Parameter description:

name is the name of the section;
loop is the array variable of the loop;
step is the step size of the loop. If step=2, it means that only the values ​​with subscripts 0, 2, and 4 are looped. If step is a negative number, it means starting from the end.
Among them, name and loop are parameters that must be filled in.

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/946758.htmlTechArticleUsage of smarty built-in function section, smarty built-in section This article describes the usage of smarty built-in function section. Share it with everyone for your reference. The specific analysis is as follows: foreach function...
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