Home  >  Article  >  Backend Development  >  How to nest loops in smarty

How to nest loops in smarty

*文
*文Original
2018-01-02 11:08:471199browse

How to nest loops in smarty? This article mainly introduces the use of section nested loops in smarty, and analyzes the implementation skills of Smarty using sections to perform nested loop operations in the form of simple examples. Friends in need can refer to it. I hope to be helpful.

The details are as follows:

{section name="sec1" loop=$typeList}
{$typeList[sec1].typeName}
{section name="sec2" loop=$typeList[sec1].shop} {/section}
{$typeList[sec1].shop[sec2].name}
数量:{$typeList[sec1].shop[sec2].num} 个
价格:{$typeList[sec1].shop[sec2].price} 白金币
{/section}

Use $typeList[sec1].shop of sec1 as the loop of sec2

You can get the contents of the array in shop

Related recommendations:

How to use variable regulator in Smarty template

How to use Smarty Generate simple form elements

Detailed explanation of how the Smarty template engine caches

The above is the detailed content of How to nest loops in smarty. 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