Php divides an array into five groups-php Tutorial

Source: Internet
Author: User
Php divides an array into five groups. Suppose $ list is a group of arrays. Contains multiple data records.

I want to divide $ list into five groups and then output them.

In the template output loop, each group ::
{Loop $ XXXX $ x} is the X group: $ A $ B $ C2 $ A $ B $ C3 $ A $ B $ C3 $ A $ B $ C4 $ A $ B $ C5 $ A $ B $ C2 $ C {/loop}


It is estimated that the first in two cycles is the total number of entries, and the second is the five in each loop.


Reply to discussion (solution)

   

Output:
12345678901

     

Output:
12345678901



All of these calls come out. how do I call the first group? How to Call Group 1

Will be traversed, not enumerated?
$ A = array_chunk (array (1, 3, 4, 5, 7, 8, 9, 0, 1), 5 );
Print_r ($ a [0]);

Will be traversed, not enumerated?
$ A = array_chunk (array (1, 3, 4, 5, 7, 8, 9, 0, 1), 5 );
Print_r ($ a [0]);



For example, I only want the template output. of course, there are no numbers in the template code.
Similar

{Loop $ xxx $ xx}
This is group X: $ a/$ B/$ c
{/Loop}

The result is like
This is the 1st Group: 1/2/3
This is the 2nd group: 4/5/6
This is the 3rd Group: 7/8/9
...............
Of course, I don't know how many groups I have.

Since a template is used, data must be transmitted as required by the template.

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.