I have this situation:
object(stdClass)#203 (1) {
["1"]=>
object(stdClass)#212 (7) {
["user_id"]=>
int(1)
["type"]=>
string(6) "Device"
["name_first"]=>
string(0) ""
["name_last"]=>
string(0) ""
["name_display"]=>
string(0) ""
["gender"]=>
string(11) "Unspecified"
["birthday"]=>
string(0) ""
}
}
I want to access either “user_id” or the [“1”], but this is of type stdclass so I can’t treat it like an array. (Note: this is from json_decode)
You have to cast it as an array: