Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]wypisanie kolekcji JSON
kyku102
post 6.04.2023, 22:05:07
Post #1





Grupa: Zarejestrowani
Postów: 3
Pomógł: 0
Dołączył: 6.04.2023

Ostrzeżenie: (0%)
-----


Witam,

mam problem z wypisaniem kolejno vehicle_model i vehicle_price. Jak powinna wyglądać poprawnie pętla foreach w PHP, która wypisze te dane z kolekcji JSON takiej jak niżej?

{
  "permissions": {
    "isGroupOwner": false,
    "warehouse": true,
    "gates": true,
    "vehicles": true,
    "lombard": true,
    "leader": true
  },
  "warehouse": {
    "id": 1600,
    "warehouseID": 4,
    "groupID": 749,
    "expires": 1680940342,
    "warehouse": {
      "id": 4,
      "price_start": 670000,
      "price_rent": 65000,
      "size": 12,
      "minimum_level": 100,
      "vehicles": [
        {
          "id": 295898,
          "vehicle_model": 451,
          "default_vehicle_price": 1570500,
          "vehicle_price": 942300,
          "stats": "[[[1680789608,1115055],[1680793211,1303515],[1680796813,1319220],[168080041
7,1963125],[1680804002,1382040],[1680807605,1633320],[1680811207,942300]]]",
          "color": "[[123,123,0,0]]"
        },
        {
          "id": 296186,
          "vehicle_model": 562,
          "default_vehicle_price": 658240,
          "vehicle_price": 579251,
          "stats": "[[[1680800417,493680],[1680804002,427856],[1680807605,454185],[1680811207,5
79251]]]",
          "color": "[[116,1,0,0]]"
        },
        {
          "id": 296206,
          "vehicle_model": 434,
          "default_vehicle_price": 609840,
          "vehicle_price": 408592,
          "stats": "[[[1680804002,548856],[1680807605,390297],[1680811207,408592]]]",
          "color": "[[1,1,0,0]]"
        },
        {
          "id": 296241,
          "vehicle_model": 562,
          "default_vehicle_price": 658240,
          "vehicle_price": 572668,
          "stats": "[[[1680811207,572668]]]",
          "color": "[[11,1,0,0]]"
        },
        {
          "id": 296254,
          "vehicle_model": 562,
          "default_vehicle_price": 658240,
          "vehicle_price": 230384,
          "stats": "[[]]",
          "color": "[[113,1,0,0]]"
        }
      ]
    }
  }
}
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 13.08.2025 - 23:02