Jump to content

[SOLVED] Accessing child objects


Psycho

Recommended Posts

I have an XML document which I am reading in via simplexml_load_file

 

Here is a sample of the output:

SimpleXMLElement Object
(
    [id] => 7870
    [title] => Apocalypse Now
    [format] => SimpleXMLElement Object
        (
            [displayname] => DVD
            [sortname] => DVD
        )
)

 

I can reference the title using $objectVariable->title. But, I cannot reference the format displayname in this manner: $objectVariable->format->displayname

 

The only way I have been able to access that value is using a two-step process such as:

$tmpVar = $objectVariable->format;
echo $tmpVar->displayname;

 

So, is there a way to access child objects of an object directly?

Link to comment
https://forums.phpfreaks.com/topic/72527-solved-accessing-child-objects/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.