我有一个看起来像这样的对象:
stdClass Object
(
[data] => stdClass Object
(
[users] => stdClass Object
(
[831C7119-FAEF-49AF-B95B-50FB492B4ACB] => stdClass Object
(
[lastName] => somename
[username] => email@email.com
[userExtId] => 831C7119-FAEF-49AF-B95B-50FB492B4ACB
[fullName] => somename somename
[firstName] => somename
[displayName] => bla bla bla
[extId] => 831C7119-FAEF-49AF-B95B-50FB492B4ACB
[password] => 12345678
)
是否可以访问说 $object->data->users->lastname ?
编辑:
function objectToArray($d) {
if (is_object($d))
$d = get_object_vars($d);
return is_array($d) ? array_map(__METHOD__, $d) : $d;
}