Home > Backend Development > PHP Tutorial > smarty内置函数section的用法_php实例

smarty内置函数section的用法_php实例

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 17:14:29
Original
967 people have browsed it

本文实例讲述了smarty内置函数section的用法。分享给大家供大家参考。具体分析如下:

foreach函数可以做到section能做的一切,所以一般都用foreach,这里也详细说下section的用法。section只能遍历索引数组,而不能遍历关联数组。

数组键值按倒序输出实例:

模板文件:temp.htm

复制代码 代码如下:
{section name=foo loop=$name step=-1}
{$name[foo]}
{/section}

参数说明:

name为section的名称;
loop为循环的数组变量;
step为循环的步长,如果step=2,表示只循环下标为0,2,4的数值,step为负数,表示从最后开始遍历。
其中name和loop为必须要填写的参数。

希望本文所述对大家的php程序设计有所帮助。

Related labels:
Statement of this Website
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
Latest Issues
smarty turns on caching garbled characters
From 1970-01-01 08:00:00
0
0
0
Why does tp use smarty template? ?
From 1970-01-01 08:00:00
0
0
0
How do you use smarty to integrate laravel5?
From 1970-01-01 08:00:00
0
0
0
Two ways to install smarty
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template