I have the following JSON object which I have decoded. I know that to access the data from the object, you would normally:
$value = $obj->data
Consider the following, where is a variable returned from the curl request
stdClass Object
(
[<account_name>] => stdClass Object
(
[id] => 123
[name] => "Some Name"
[email] = "someguy@somemail.net"
)
)
How do I get the values of [id]
, [name]
, [email]
etc, if I do not know the object key?
If you use json_decode
, set the second parameter to true
to decode the json data to an array.
Then you could use foreach
to loop the array even you do not know the key.
This function will most likely be able to help you. Get_Object_vars