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