PHP converts a one-dimensional array to a two-dimensional array of 3 consecutive values, dimension two-dimensional array _php tutorial

Source: Internet
Author: User
Tags php regular expression

PHP converts a one-dimensional array to a two-dimensional array of 3 consecutive values, a two-dimensional array of dimensions


The example in this paper describes the PHP implementation of converting a one-dimensional array into a two-dimensional array of 3 consecutive values. Share to everyone for your reference, as follows:

<?PHP$AAA = Array (' AA ', ' BB ', ' cc ', ' dd ', ' ee ', ' ff ', ' GG ', ' hh ', ' II '); for ($i =0; $i <3; $i + +) {  $bbb [] = Array_ Slice ($AAA, $i * 3, 3);} Print_r ($BBB);? >

The results of the operation are as follows:

Array (  [0] = = Array    (      [0] = AA      [1] = BB      [2] = + cc    )  [1] = = Array    (      [0] = DD      [1] = EE      [2] = = FF    )  [2] = = Array    (      [0] = = GG      [1] = = Hh
  [2] (= II    ))

Key code:

$bbb [] = Array_slice ($AAA, $i * 3, 3),//3 is 3 groups, if 2 is 2 a group

More about PHP related content readers can view this site topic: "PHP array" operation Skills Daquan, "PHP Sorting algorithm Summary", "PHP common traversal algorithm and skills summary", "PHP Data structure and algorithm tutorial", "PHP Programming Algorithm Summary", " PHP Math Skills Summary, "PHP Regular Expression Usage summary", "PHP Operations and Operator Usage Summary", "PHP string Usage Summary" and "PHP common database Operation Skills Summary"

I hope this article is helpful to you in PHP programming.

http://www.bkjia.com/PHPjc/1123794.html www.bkjia.com true http://www.bkjia.com/PHPjc/1123794.html techarticle PHP Converts a one-dimensional array to a two-dimensional array of 3 consecutive values, a two-dimensional array of dimensionality This article describes the PHP implementation of converting a one-dimensional array into a two-dimensional array of 3 consecutive values. Points ...

  • Related Article

    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.