Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Ajvanho's avatar
Level 14

read json data from weather api

I try to use json data from weather api. How to read this data from $obj.

dd($obj);

{#522 ▼
  +"coord": {#524 ▶}
  +"weather": array:1 [▼
    0 => {#509 ▼
      +"id": 300
      +"main": "Drizzle"
      +"description": "light intensity drizzle"
      +"icon": "09d"
    }
  ]
  +"base": "stations"
  +"main": {#518 ▶}
  +"visibility": 10000
  +"wind": {#512 ▶}
  +"clouds": {#511 ▶}
  +"dt": 1485789600
  +"sys": {#508 ▶}
  +"id": 2643743
  +"name": "London"
  +"cod": 200
}
0 likes
2 replies
Sti3bas's avatar
Sti3bas
Best Answer
Level 53

How to read this data from $obj

Which data? It's an object, you can access any field with $obj->field, for example $object->weather[0]->description.

Ajvanho's avatar
Level 14

Thank you very much. I am trying to understand this area, but nowhere can I find a good explanation. This is what I need for now.

Please or to participate in this conversation.