Skip to content
Advertisement

Echo specific value of a key of an array generated from an XML

I have the following code:

JavaScript

That returns the following result:

JavaScript

Now I want to echo the value of “CHANGEDATE”, but echo $array["note"]["RESPONSE"]["CHANGE"]["TEST"]["CHANGEBY"]; returns nothing.

Advertisement

Answer

There’s no need to go to JSON, you can use your SimpleXML object directly:

JavaScript

However, if you really want/need to, the root element note needs to be skipped:

JavaScript

Demo: https://3v4l.org/fbTpB

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement