🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
### foreach循环 ~~~ /** * 模版标签例子 * 视图文件位置: /application/example/view/ViewController/foreachExample.html * @return string */ public function foreachExample() { $user = [ [ 'name' => 'lily', 'age' => 18, ], [ 'name' => 'tom', 'age' => 19, ], ]; $this->assign('user', $user); return $this->fetch(); } ~~~ ~~~ <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>fetch</title> </head> <body> <h2>I am __ROOT__/application/example/view/ViewExample/foreachExample.html</h2> <table border="1"> <foreach name='user' item='v'> <tr> <th>名字</th> <th>年龄</th> </tr> <tr> <td>{$v['name']}</td> <td>{$v['age']}</td> </tr> </foreach> </table> </body> </html> ~~~