search
HomeCMS TutorialPHPCMSHow to use loop tag in phpcms

How to use loop tag in phpcms

Feb 08, 2020 am 10:43 AM
loopphpcmsLabel

How to use loop tag in phpcms

In phpcms, loops are used a lot, generally in two forms.

The form is as follows:

Form one:

{loop $data $a}
{$a}
{/loop}

Form two:

{loop $data $a $b}
{$a}---{$b}
{/loop}

The difference is as follows:

First of all, $data is an array. In the first form, the $data array is like this, "aa", "bb", "cc". In this form, To get the first value aa, we use this code $data[0], to get the second value we use $data[1], and so on.

Form 2, the $data array has an additional key value, which is in this form "a1=>aa", "a2=>bb", "a3=>cc", a1, a2 , a3 is called the key value of $data. If we want to take out the variable value with the key value a1, that is, aa, we can use $data[a1] to get aa. Similarly, $data[a2] also It’s just bb.

Then in PHPCMS, form 1:

In the loop, $a is $data[0], $data[1], $data[2], we directly write {$ a} can loop to get the value of $a.

Form 2:

In the loop, $a is a1, a2, a3 in the above example, and $b is aa, bb, cc in the above example.

The examples are as follows:

Example 1: There are three values ​​​​"aa", "bb", "cc" in the

$data array, then :

{loop $data $a}
{$a}
{/loop}

will output aa, bb, cc.

Example 2:

There are three key values ​​in the $data array: "a1=>aa", "a2=>bb", "a3=>cc", Then

{loop $data $a $b}
{$a}-{$b}|
{/loop}

will output a1-aa|a2-bb|a3-cc|.

Related tutorial recommendations: phpcms tutorial

The above is the detailed content of How to use loop tag in phpcms. For more information, please follow other related articles on the PHP Chinese website!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version