无法访问包含 @ 符号的数组对象


Unable to access the array object that contains @ sign

我有一个数组,在对象中包含@sign。我无法访问那个
实际上我正在将XML解析为数组
print_r输出如下

[link] => SimpleXMLElement Object
                        (
                            [@attributes] => Array
                                (
                                    [type] => text/html
                                    [href] => http://www.livingsocial.com/cities/1964-klang-valley-kuala-lumpur/deals/393950-2-pax-steamboat-set-2-iced-lemon-tea
                                    [rel] => alternate
                                )
                        )



$entry->链接->@attributes->href
无法访问

您必须使用 attributes() 方法从 SimpleXMLElement 对象中获取属性

 $entry->link->attributes();

如果要将 href 属性作为字符串获取,可以执行以下操作:

$href = $entry->link->attributes()->href->__toString();