Home > Article > Backend Development > Overview of using the foreach tag in ThinkPHP_PHP Tutorial
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>
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.