【发布时间】:2014-03-16 13:56:03
【问题描述】:
我有以下 XML
SimpleXMLElement Object
(
[active-until] => 2015-03-16T13:45:32Z
[billing-first-name] => rriiggiidd
[billing-last-name] => smith
[created-at] => 2014-03-16T13:45:32Z
[customer-id] => 50
[eligible-for-free-trial] => false
[email] => rigids.php2@gmail.com
[expired-at] => SimpleXMLElement Object
(
[@attributes] => Array
(
[type] => datetime
[nil] => true
)
)
)
我想获取 customer-id 和 email 的值
我使用的代码为echo $xml->email;
它对我有用,但是当我对customer-id 使用相同的echo $xml->customer-id; 时
不起作用(可能是因为它包含(-))
如果有连字符 (-),任何人都可以建议如何访问值。
非常感谢任何帮助。
【问题讨论】:
-
Hyphens in Keys of Object 的可能重复项