thinkphp example of an array loop in a template, thinkphp template _php Tutorial

Source: Internet
Author: User

Thinkphp array Loop instance in template, thinkphp template


This article describes the implementation of array loops in thinkphp templates. Share to everyone for your reference. The implementation method is as follows:

thinkphp development process is often used in the output array used in the template, the general select out of the data are two-dimensional array, we use the template volist label can be output, today development encountered a problem: if it is a two-dimensional array, how to output in the template? After reviewing the development manual, the problem is solved and shared, such as a one-dimensional array:

Copy the Code code as follows: Array (2) {
[2] = = string () "Www.jb51.net Blog with Picture"
[3] = = string (12) "Default album"
}
With the foreach tag, he can loop one-dimensional or two-dimensional arrays, one-dimensional arrays that use:

Copy the Code code as follows:{$VO}

It is hoped that this article will be helpful to everyone's thinkphp framework design.


thinkphp looping an array on a template I've already set the length of the arrays how to judge the last of the loops

Are you sure you want to go to the total page number? thinkphp with the page display should be {$page}, the default display is the number of n records, the previous page, the next page, the first page, the last page, to show the total page configuration page.class.php in the $config item

How do I combine loops and functions in a thinkphp in a template?

You query this out is a two-dimensional array, in the template has a special label for the loop output, so unnecessary to calculate his length, you directly with Volist this label
Use the following:

Show title: {$vo. Name}
</volist>
The value of name books is the two-dimensional array name you passed in the controller.

http://www.bkjia.com/PHPjc/903477.html www.bkjia.com true http://www.bkjia.com/PHPjc/903477.html techarticle thinkphp Example of an array loop in a template, thinkphp template This article describes the implementation of the array loop in the thinkphp template. Share to everyone for your reference. The concrete implementation method is as follows: ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.