How can I create an array of type
<?php [ array( "name" => "Щи", "amount" => 1, "code" => "00031", "sum" => 80 ), array( "name" => "Салат Коул-слоу", "amount" => 2, "code" => "0027", "sum" => 200 ) ] From Decoded JSON
<?php array(5) { ["Пепперони"]=> array(6) { ["price"]=> string(3) "440" ["quantity"]=> string(1) "3" ["description"]=> string(0) "" ["totalPrice"]=> int(1320) ["name"]=> string(18) "Пепперони" ["productSize"]=> string(7) "40 см" } ["4 сезона"]=> array(7) { ["price"]=> int(690) ["quantity"]=> string(1) "1" ["description"]=> string(188) "Томатный соус, орегано, кубики брынзы, шампиньоны, томаты, ветчина, пикантная пепперони и сыр моцарелла" ["totalPrice"]=> int(690) ["name"]=> string(14) "4 сезона" ["image"]=> string(31) "assets/img/catalog/4seasons.JPG" ["productSize"]=> string(7) "40 см" } ["Земная"]=> array(6) { ["price"]=> string(3) "590" ["quantity"]=> string(1) "2" ["description"]=> string(0) "" ["totalPrice"]=> int(1180) ["name"]=> string(12) "Земная" ["productSize"]=> string(7) "20 см" } ["Компания"]=> array(6) { ["price"]=> int(2600) ["quantity"]=> string(1) "1" ["description"]=> string(151) "Земная 40 см, Цыпленок барбекю 40 см, 4 сезона 40 см, Шеф бекон 40 см, Сырный цыпленок 40 см" ["totalPrice"]=> int(2600) ["name"]=> string(16) "Компания" ["image"]=> string(32) "assets/img/kombo/company-min.jpg" } ["Бон аква не газ (0,5л)"]=> array(6) { ["price"]=> int(80) ["quantity"]=> string(1) "1" ["description"]=> string(0) "" ["totalPrice"]=> int(80) ["name"]=> string(35) "Бон аква не газ (0,5л)" ["image"]=> string(30) "assets/img/drinks/bonnegaz.jpg" } } //JSON /* string(1114) "{"Пепперони":{"price":"440","quantity":"3","description":"","totalPrice":1320,"name":"Пепперони","productSize":"40 см"},"4 сезона":{"price":690,"quantity":"1","description":"Томатный соус, орегано, кубики брынзы, шампиньоны, томаты, ветчина, пикантная пепперони и сыр моцарелла","totalPrice":690,"name":"4 сезона","image":"assets/img/catalog/4seasons.JPG","productSize":"40 см"},"Земная":{"price":"590","quantity":"2","description":"","totalPrice":1180,"name":"Земная","productSize":"20 см"},"Компания":{"price":2600,"quantity":"1","description":"Земная 40 см, Цыпленок барбекю 40 см, 4 сезона 40 см, Шеф бекон 40 см, Сырный цыпленок 40 см","totalPrice":2600,"name":"Компания","image":"assets/img/kombo/company-min.jpg"},"Бон аква не газ (0,5л)":{"price":80,"quantity":"1","description":"","totalPrice":80,"name":"Бон аква не газ (0,5л)","image":"assets/img/drinks/bonnegaz.jpg"}}" */ Thanks a lot in advance!
foreach ($json as $key => $value){ if (is_array($value)) { foreach ($value as $key2 => $value2){ echo $key2 . " => " . $value2 . "<br>"; } } }foreach ($json as $key => $value){ if (is_array($value)) { foreach ($value as $key2 => $value2){ echo $key2 . " => " . $value2 . "<br>"; } } }foreach ($json as $key => $value){ if (is_array($value)) { foreach ($value as $key2 => $value2){ echo $key2 . " => " . $value2 . "<br>"; } } }- but here I can’t figure out how to eat the products into separate arrays, now they are all in a heap - Sergey Kozin