开发者

How i can access an object in php

开发者 https://www.devze.com 2023-01-24 10:51 出处:网络
Please see object array which i print here:开发者_如何学C SimpleXMLElement Object ( [@attributes] => Array

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

精彩评论

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

关注公众号