Home > php教程 > php手册 > body text

ThinkPHP模板中数组循环实例

WBOY
Release: 2016-06-06 20:18:53
Original
1344 people have browsed it

这篇文章主要介绍了ThinkPHP模板中数组循环,以实例形式展示了ThinkPHP采用foreach标签循环输出数组的方法,需要的朋友可以参考下

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

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

复制代码 代码如下:

array(2) {
[2] => string(12) "www.jb51.net博文配图"
[3] => string(12) "默认相册"
}


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

复制代码 代码如下:

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!