从PHP中的SimpleXMLElement访问值
我有以下XML从PHP中的SimpleXMLElement访问值,php,xml,Php,Xml,我有以下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-tria
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
)
)
)
我想获取客户id
和电子邮件
我使用的代码是echo$xml->email代码>
它对我有用,但当我对customer id
使用它时,就像echo$xml->customer id代码>
它不起作用(可能是因为它包含(-)
如果值有连字符(-),是否有人可以建议如何访问该值
非常感谢您的帮助。请尝试以下空间
$object->{'object-property'};
因此,在你的情况下,它将是
$xml->{'customer-id'};
等。可能重复的