如何打印嵌套的stdclass对象数组

问题描述:

I am trying to print values in this nested stdClass Object but I'm having trouble accessing them. How do I print the ID?

stdClass Object (
    [AddUserWithLimitResult] => stdClass Object (
        [Header] => stdClass Object ( 
            [Code] => UserAdded
            [Description] => User created
        )
        [ID] => 2243272
        [UserName] => gmail.com
        [FirstName] => sar 
        [LastName] => Sea
        [Email] => gmail.com 
        [SubDomain] => olo
    )
) 

I tried this:

$object->AddUserWithLimitResult->Header->Code->ID;

我试图在这个嵌套的stdClass对象中打印值,但是我无法访问它们。 如何打印ID? p>

  stdClass对象(
 [AddUserWithLimitResult] => stdClass对象(
 [Header] => stdClass对象(
 [代码]  ] => UserAdded 
 [描述] =>用户创建
)
 [ID] => 2243272 
 [用户名] => gmail.com 
 [FirstName] => sar 
 [  LastName] => Sea 
 [电子邮件] => gmail.com 
 [SubDomain] => olo 
)
)
  code>  pre> 
 
 

I 试过这个: p>

  $ object-> AddUserWithLimitResult-> Header-> Code-> ID; 
  code>  pre> 
   DIV>

If you tab out the output it becomes clear that ID is a property of AddUserWithLimitResult

stdClass Object ( 
    [AddUserWithLimitResult] => stdClass Object (
        [Header] => stdClass Object (
            [Code] => UserAdded 
            [Description] => User created 
        )
        [ID] => 2243272 
        [UserName] => gmail.com
        [FirstName] => sar 
        [LastName] => Sea 
        [Email] => gmail.com 
        [SubDomain] => olo 
    ) 
)

$object->AddUserWithLimitResult->ID

Edit: It looks like you updated the question with the tabbed code. When I saw it it was difficult to tell which properties belonged to which objects.