从PHP中的SimpleXMLElement访问值

从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

我有以下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
                  )

       )
)
我想获取
客户id
电子邮件
我使用的代码是
echo$xml->email

它对我有用,但当我对
customer id
使用它时,就像
echo$xml->customer id

它不起作用(可能是因为它包含(-

如果值有连字符(-),是否有人可以建议如何访问该值


非常感谢您的帮助。

请尝试以下空间

$object->{'object-property'};
因此,在你的情况下,它将是

$xml->{'customer-id'};  
等。

可能重复的