首页
开发手册
应用中心
工具
用户中心
Ease Template Nested Loop
English
中文简体
English
上一篇
下一篇
### Ease Template Nested Loop What is a nested loop, the most common is the menu, as shown in the figure: ![](data/files/edit/20/12/10/201210_17086080.png) Nested loop should be a must-use method for menu development. Two arrays are created in the php program, namely category $cate and subcategory $sub. Arrange the array of subcategory sub corresponding to the category array to achieve nested loop effect. In the figure, a set of nested loops is realized by wrapping the inner loop by the outer loop ![](data/files/edit/20/12/10/201210_17249720.jpg) **Example:** test_6.php ```php '分类1',1=>'分类2',2=>'分类3'); //subclass array $sub = array( 0=>array('Computer','newspaper','magazine','mouse'), 1=>array(''Green cabbage',' cabbage'), 2=>array(''Orange','Banana','Apple') ); $tpl->set_file('test_6'); $tpl->p(); ?> ``` The method for Ease Template to nest loops in the template is to loop $cate first, and then assign the loop id:$ck to $sub by calling the loop $cate's loop id:$ck, the corresponding subclass of the loop can get the data, and the nested loop is completed. view/test_6.htm ``` Nested loop:
{cv}
->{V}
```