json - Parsing a timestamp based PHP std class obkect -
i have php standard class object converted json_decode of rest call on api looks :
array ( [1437688713] => stdclass object ( [handle] => keep logically awesome. [id] => 377748 [ping] => stdclass object ( [url] => https://api.me.com [id] => 377748 [name] => web [active] => 1 [events] => array ( [0] => data_new [1] => data_old )
so far had no issues in parsing of php objects. 1 failing because can not access nested object elements using key since 1437688713 not assigned key , accessing object failing if try this:
$object->1437688713->handle
is there way access these elements ?
update: 1 more thing, never know value (1437688713) in advance. key. stdclass object have parse.
the outer part of data array, not object. try:
$array['1437688713']->handle;
or if don't know key, can iterate on array (handy if may contain multiple objects too):
foreach ($array $key => $object) { echo $key; // outputs: 1437688713 echo $object->handle; // outputs: keep logically awesome. }
Comments
Post a Comment