Example of array loop in ThinkPHP template, thinkphp template_PHP tutorial

WBOY
Release: 2016-07-13 10:15:43
Original
1058 people have browsed it

Array loop example in ThinkPHP template, thinkphp template

The example in this article describes the implementation method of array loop in ThinkPHP template. Share it with everyone for your reference. The specific implementation method is as follows:

In the development process of ThinkPHP, output arrays are often used in templates. Generally, the selected data is a two-dimensional array. We can output it by using the volist tag in the template. Today, we encountered such a problem in development: If it is a two-dimensional array, How to output a dimensional array in a template? After checking the development manual, the problem was solved. Let me share it, such as this one-dimensional array:

Copy code The code is as follows:
array(2) {
[2] => string(12) "www.jb51.net blog post with pictures"
[3] => string(12) "Default album"
}

Using the foreach tag, he can loop through one-dimensional or two-dimensional arrays. One-dimensional arrays can be used like this:

Copy code The code is as follows:

I hope this article will be helpful to everyone’s ThinkPHP framework programming.

thinkphp loops an array on the template. I have found the length of the array. How to judge whether it is the last time of the loop

Are you sure you want to go to the total page number? The paging page display using ThinkPHP's own should be {$page}. The default display is the number of N records, the previous page, the next page, the first page, and the last page. To display the total number of pages, configure the page. $config item in class.php

How do I combine a loop with a function in a template in thinkphp?

What you query like this is a two-dimensional array. There is a special label in the template for loop output, so there is no need to calculate its length. You can directly use the volist label
The usage is as follows:

Display book name: {$vo.name}

The value of books is what you have in the controller The passed two-dimensional array name

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/903477.htmlTechArticleExample of array loop in ThinkPHP template, thinkphp template This article describes the implementation method of array loop in ThinkPHP template. Share it with everyone for your reference. The specific implementation method is as follows:...
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 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!