1

I want to return an array structure using simple XML. Everything fine, except when the XML has a tag with the same name as a PHP variable, like return.

Example:

$msg = simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA);

Return

$msg->dynamics->details->flight->return-leg->airport;

How can I parse the return tag? I've tried something like {return-leg} but I get still error.

Any idea?

Ataboy Josef
  • 2,087
  • 3
  • 22
  • 27
pedroF
  • 11
  • 3

1 Answers1

1

Try this way:

$msg->dynamics->details->flight->{'return-leg'}->airport

You can check examples here:

PHP DOC

lmarcelocc
  • 1,301
  • 11
  • 21