I need to convert an array in this format:
Array (
[size] => P
[code] => Array (
[0] => C01
[1] => B01
[2] = A02
)
)
to multiple ones like this:
Array ( [size] => P [code] => C01 )
Array ( [size] => P [code] => B01 )
Array ( [size] => P [code] => A02 )
How would I do that using php code?
You need to loop throught items of code
array and push values into new array or new variable.
foreach($arr["code"] as $item){
@$newArr[] = [
"size" => "P",
"code" => $item
];
}
var_dump($newArr);
Check code result in demo
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments