Adeel Akram
Adeel Akram

Reputation: 390

conversion of json

hi guys i'm working to show weather updates on my website. for that i'm sending some code which is returning me some thing like below

stdClass Object
(
    [data] => stdClass Object
        (
            [current_condition] => Array
                (
                    [0] => stdClass Object
                        (
                            [temp_C] => 26
                            [temp_F] => 79
                        )



                )
        )
)

i want to fetch the temp_C which is somewhere beneath [o]=>stdClass Object for that purpose i used the statment like this

//$returning is variable have all the json in it
$celcius = $returning->data->current_condition->0->temp_c;

kindly guide me how to get temp_C,,,i'm currently working with php. Thankx to all

Upvotes: 0

Views: 43

Answers (1)

Ayush
Ayush

Reputation: 42450

current_condition is an array

$celcius = $returning->data->current_condition[0]->temp_c;

Upvotes: 1

Related Questions