Email as the name of the object

I have XML with a node called 'e-mail'. I use simplexml_load_file to read the file, but when I want to get the value of a string using $ row-> e-mail, I only get 0 back.

What is wrong here, all the other names work fine, so I think this has something to do with mail.

Tnx

+3
source share
2 answers

From the manual

Access to elements inside an XML document containing characters is not permitted using PHP names (for example, a hyphen) can be achieved by encapsulating the element name in curly brackets and an apostrophe.

echo $ Xml-> movie → {'great-grandchildren of the line'} → line;

So you need something like

$row->{'e-mail'}
+4
source

This should work:

$row->{'e-mail'}
+3
source

Source: https://habr.com/ru/post/1763103/


All Articles