3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [ "size" => "P", "code" => ["C01","B01","A02"] ]; foreach($arr["code"] as $item){ @$newArr[] = [ "size" => "P", "code" => $item ]; } var_dump($newArr);
Output for 5.6.0 - 5.6.27, 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
array(3) { [0]=> array(2) { ["size"]=> string(1) "P" ["code"]=> string(3) "C01" } [1]=> array(2) { ["size"]=> string(1) "P" ["code"]=> string(3) "B01" } [2]=> array(2) { ["size"]=> string(1) "P" ["code"]=> string(3) "A02" } }

preferences:
166.37 ms | 404 KiB | 203 Q