开发者

e-mail as object name

I have a XML with a node called 'e-mail'. I use simplexml_load_file to read the fi开发者_StackOverflow中文版le but when i want to get the row value with $row->e-mail i get just get 0 back.

What's wrong here, all other names work fine so i think it has something to do with 'mail'.

tnx


From the manual

Accessing elements within an XML document that contain characters not permitted under PHP's naming convention (e.g. the hyphen) can be accomplished by encapsulating the element name within braces and the apostrophe.

echo $xml->movie->{'great-lines'}->line;

So you need something like

$row->{'e-mail'}


This should work:

$row->{'e-mail'}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜