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

问题描述:

我正在尝试在此嵌套的stdClass对象中打印值,但是在访问它们时遇到了麻烦.如何打印ID?

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
    )
) 

我尝试过:

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

如果您将输出选项卡出,则很明显ID是AddUserWithLimitResult的属性

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

您似乎已使用选项卡式代码更新了问题.当我看到它时,很难分辨出哪些属性属于哪些对象.

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.