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

ThinkPHP之foreach标签使用概述

WBOY
WBOYOriginal
2016-06-13 09:32:051168browse

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>

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

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