php and nested json: how can i access this element?

前端 未结 3 1720
迷失自我
迷失自我 2021-01-02 07:51

Here\'s the json text:

{
\"data\": {
    \"current_condition\": [{
        \"cloudcover\": \"75\",
        \"humidity\": \"63\",
        \"observation_time\"         


        
3条回答
  •  猫巷女王i
    2021-01-02 08:19

    json_decode() with TRUE as second parameter gives you an associative array. But you're currently trying to access it as an object.

    Try the following:

    echo $arr['data']['current_condition'][0]['temp_F'];
    

提交回复
热议问题