how to get json value with php

前端 未结 2 1397
萌比男神i
萌比男神i 2021-01-28 20:24

Here parameters of API respond :

{\"cod\":\"200\",\"message\":0.0045,
\"city\":{\"id\":1851632,\"name\":\"Shuzenji\",
\"coord\":{\"lon\":138.933334,\"lat\":34.96         


        
相关标签:
2条回答
  • 2021-01-28 21:01

    First, make sure you have decoded the json.

    $decodedData = json_decode($data);
    

    Then, try accessing the object's properties and arrays like this:

    echo $decodedData->list[0]->weather[0]->description;
    
    0 讨论(0)
  • 2021-01-28 21:17

    It looks like 'weather' is an array.

    Try $data['list'][0]['weather'][0]['description'];

    0 讨论(0)
提交回复
热议问题