Working with three-dimensional arrays, re-grouping

Source: Internet
Author: User

0x01

In a three-dimensional array, select the data, and regroup it from the SF record

Code:

-------

function Combinedika ($data) {    $result = array ();    foreach (Array_shift ($data) as $k = + $item) {        $result [] = Array ($k + = $item);    }    foreach ($data as $k = = $v) {        $result 2 = [];        foreach ($result as $k 1=> $item 1) {            foreach ($v as $k 2=> $item 2) {                $temp     = $item 1;                $temp [$k 2]   = $item 2;                $result 2[] = $temp;            }        }        $result = $result 2;    }    return $result;} $skuattr = Array ('    7 ' = =  array    (        ' 6 ' = ' = ' 22x33 ',        ' 9 ' = ' 44x55 ',    ),    ' 8 '  = = Array    (        ' + ' = ' size '    ),    ' 9 '  = = Array    (        ' 8 '  = ' metal ', '        ' + ' = ' plastic '),    ),    ' + ' = Array (' + ' = ' round ') ')    ; $a = Combinedika ($skuattr);p rint_r ($a);

0x02

Three-dimensional arrays into two-dimensional arrays

<?php    $array = Array (' 0 ' =>array (' 1 ' = ' a ', ' 2 ' = = ' B '),
' 1 ' =>array (' 3 ' = ' C ', ' 4 ' = ' d '),
); foreach ($array as $key = + $value) { foreach ($value as $k + = $v) { $data [] = $v; } } Print_r ($data);? >

  

Working with three-dimensional arrays, re-grouping

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.