PHP, getting Undefined property: stdClass::$id but it definitely exists
object, php
Solution
How do you access to individual properties is based on your data structure. You have kind of nested structure, object in object. Try like this:
$somename->somename->id;
//or
$yourObjectName->somename->id;
I hope this helps!
Problem
So it's really simple code and I am yanking my hair out with the problem. ``` //I first retrieve some JSON info (confirmed to work fine) $file=file_get_contents('url'); //I then decode and print to verify (still working) $somename=json_decode($file); ``` I print it out just to make sure it works (it does): ``` print_r($somename); ``` The print out reads as follows: ``` stdClass Object ( [id] => 456456456 [name] => somename [Stuff01] => 55 [Stuff02] => 25 [Stuff03] => 123132123132 ) ) ``` Now I just want to get the value in the 'id' key so I use the appropriate object call: ``` $thisID=$somename->{'id'}; ``` But I get the error: Notice: Undefined property: `stdClass::$id` I print_r every time so I know it's there. I can see it. What am I doing wrong? I have had no problems doing this exact thing many times.