Home > php教程 > php手册 > ThinkPHP之foreach标签使用概述

ThinkPHP之foreach标签使用概述

WBOY
Release: 2016-06-13 09:32:05
Original
1220 people have browsed it

ThinkPHP模板的foreach标签用于在模板中循环输出数据集或者对对象进行遍历输出。

相对于volist标签而言,foreach标签没有volist标签那么多的功能,却可以对对象进行遍历输出,而volist标签通常是用于输出数组。

foreach标签用法如下:

<foreach name="list" item="vo">
用 户 名:{$vo.username}<br />
电子邮件:{$vo.email}<br />
注册时间:{$vo.regdate|date="Y-m-d H:i",###}
<hr />
</foreach>
Copy after login

foreach标签中的name为必选项,表示要输出的模板变量;item也是必选项,表示循环单元变量。

Related labels:
source:php.cn
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template