How i can access an object in php
Please see object array which i print here:
开发者_如何学CSimpleXMLElement Object ( [@attributes] => Array ( [generator-info-name] => www.ontv.dk/xmltv )
[channel] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[id] => www.ontv.dk/tv/1
)
[display-name] => DR1 DK
)
)
How I can access channel-->display-name
Below code is not working:
echo $obj->channel[0]->display-name;
Help me please
Property names with dashes must be quoted properly:
echo $obj->channel[0]->{'display-name'};
Otherwise, the parser sees it as an arithmetic operation (i.e: $obj->channel[0]->display minus name).
精彩评论