Home > Backend Development > PHP Tutorial > Overview of using the foreach tag in ThinkPHP_PHP Tutorial

Overview of using the foreach tag in ThinkPHP_PHP Tutorial

WBOY
Release: 2016-07-13 10:26:23
Original
921 people have browsed it

The foreach tag of ThinkPHP template is used to loop output data sets or traverse objects in the template.

Compared to the volist tag, the foreach tag does not have as many functions as the volist tag, but it can traverse objects and output , while the volist tag is usually used to output arrays.

The foreach tag is used as follows:

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

The name in the foreach tag is a required option, indicating the template variable to be output; item is also a required option, indicating the loop unit variable.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/824726.htmlTechArticleThe foreach tag of ThinkPHP template is used to loop the output data set in the template or traverse the object. Compared with the volist tag, the foreach tag does not have as many functions as the volist tag...
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template