how to get json value with php

前端 未结 2 1396
萌比男神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;
    

提交回复
热议问题