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:
I hope this article will be helpful to everyone’s ThinkPHP framework programming.
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
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