[
"quantity" => [
0 => 1
1 => 2
2 => 3
3 => 4
]
"color" => [
0 => 5
1 => 6
2 => 7
3 => 8
]
]
[
0 => [
"quantity" => 1
"color" => 5
]
1 => [
"quantity" => 2
"color" => 6
]
2 => [
"quantity" => 3
"color" => 7
]
3 => [
"quantity" => 4
"color" => 8
]
]
$input = [
"quantity" => [0=>1, 1=>2, 2=>3, 3=>4],
"color" => [0=>5, 1=>6, 2=>7, 3=>8],
];
$result = [];
foreach( $input as $propertyName => $values ) {
foreach ($values as $index => $value) {
$result[$index][$propertyName] = $value;
}
}
print_r($result);
<?php
$input = [
'quantity' => [0=>1, 1=>2, 2=>3, 3=>4],
'color' => [0=>5, 1=>6, 2=>7, 3=>8],
];
$output = array_map(function ($first, $second) {
return [
'quantity' => $first,
'color' => $second,
];
}, $input['quantity'], $input['color']);
var_dump($output);