Home  >  Article  >  Backend Development  >  ThinkPHP模板中数组循环实例_php实例

ThinkPHP模板中数组循环实例_php实例

WBOY
WBOYOriginal
2016-06-07 17:15:47621browse

本文实例讲述了ThinkPHP模板中数组循环的实现方法。分享给大家供大家参考。具体实现方法如下:

ThinkPHP开发过程中经常用到输出数组在模板中使用,一般select出来的数据都是二维数组,我们在模板中用volist标签就可以输出,今天开发遇到了这样一个问题:如果是二维数组,如何在模板中输出呢?经过查看开发手册,问题得到解决,分享一下,比如这样的一维数组:

复制代码 代码如下:
array(2) {
[2] => string(12) "www.php.net博文配图"
[3] => string(12) "默认相册"
}

用到foreach标签,他可以循环一维或者是二维数组,一维数组这样用:

复制代码 代码如下:

希望本文所述对大家的ThinkPHP框架程序设计有所帮助。

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