How does the array go horizontally?
Array
6=>array (5=> ' Black xx ', 42=> ' XXL '),
7=>array (5=> ' Black xx ', 40=> ' XL '),
8=>array (8=> ' Ash ', 40=> ' XL '),
);
Results:
Array
0=>array (5=> ' Black xx ', 8=> ' ash '),
1=>array (42=> ' XXL ', 40=> ' XL '),
);
How does the array go horizontally and filter for duplicate values?
------Solution--------------------
$arr = Array (
6=>array (5=> ' Black xx ', 42=> ' XXL '),
7=>array (5=> ' Black xx ', 40=> ' XL '),
8=>array (8=> ' Ash ', 40=> ' XL '),
);
$result = Array ();
foreach ($arr as $a) {
$keys = Array_keys ($a);
$vals = array_values ($a);
$result [0][$keys [0]] = $vals [0];
$result [1][$keys [1]] = $vals [1];
}
Print_r ($result);
Array
(
[0] = = Array
(
[5] = black XX
[8] = Ash
)
[1] = = Array
(
[All] + XXL
[+] = XL
)
)
------Solution--------------------
The simplest notation
$a = Array (
6=>array (5=> ' Black xx ', 42=> ' XXL '),
7=>array (5=> ' Black xx ', 40=> ' XL '),
8=>array (8=> ' Ash ', 40=> ' XL '),
);
foreach ($a as $r) {
$i = 0;
while (list ($k, $v) = each ($r)) $b [$i ++][$k] = $v;
}
Print_r ($b);
Array
(
[0] = = Array
(
[5] = black XX
[8] = Ash
)
[1] = = Array
(
[All] + XXL
[+] = XL
)
)