开发者

How i can access an object in php

Please see object array which i print here:

开发者_如何学C

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜