1.foreach tag
foreach tag is used for loop output:
foreach(name, item, key)
name (required): the data template variable to be output
item (required): loop single original variable
key (optional) : The key variable of the loop, the default value is key
Example:
{$vo.id}
{$vo.name}
The foreach tag is simpler than the volist tag and does not have as many functions as the volist tag. The advantage is that objects can be traversed and output, and the volist tag is usually used to output arrays.
2.volist tag
volist tag is mainly used to loop through the output of data sets or multi-dimensional arrays in templates
volist(name, id, offset, length, key, mod, empty)
name (required): the data model to be output Variable
id (required): loop variable
offset (optional): offset of the data to be output
length (optional): length of the output data
key (optional): key variable of the loop, the default value is i
mod (Optional): Modulo the key value, the default is 2 (used for even-numbered row queries, etc.)
empty (optional): The string displayed if the data is empty
Usually the result returned by the select method of the model is a two Dimensional arrays can be output directly using the volist tag.
First assign a value to the template in Action:
$user=M('User');
$list=$user->select();
$this->assign('list',$list);
$this->display();
The template is defined as follows, output the number and name
{$vo.id}
{$vo.name}
Supports outputting partial data, such as outputting the 5th-15th records:
{ $vo.id}
{$vo.name}
Output even-numbered row records:
The mod attribute is also used to control the line wrapping of certain records:
{$vo.name}
Output loop variable:
{$k}.{$vo.name}
If key is not specified For attributes, the loop variable i is used by default, for example:
{$i}.{$vo.name}
If you want to output the index of the array, you can use the key variable directly. Unlike the loop variable, the key is determined by the data itself, not controlled by the loop, for example:
{$key}.{$vo.name}
volist also has an alias iterate, and its usage is the same as volist.
Starting from version 2.1, functions are allowed to be used to set data sets, such as:

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool
