After getting a json from Youtube API. I used this code to parse it:
$en = json_encode($json, true);
echo "<pre>";
print_r($en);
echo "</pre>";
here is the result:
{"items":[{"id":"UC-D8SQfw-J-lSWFSbyX6wRg"}]}
I made it clear with an online json parser here's how it looks:
{
"items":[
{
"id":"UC-D8SQfw-J-lSWFSbyX6wRg"
}
]
}
I want to get id
value. I have tried $en->items->id
but it says Notice: Trying to get property of non-object
how do I get the value of id
?
$en = json_encode($json, true);
$en_b = json_decode($en, true);
echo $en_b['items'][0]['id'];