Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rotexdegba/1c50627b16afd94f9793 to your computer and use it in GitHub Desktop.
Save rotexdegba/1c50627b16afd94f9793 to your computer and use it in GitHub Desktop.
How to Quickly Convert Xml Read into a SimpleXMLElement object into PHP Objects
<?php
$url = 'http://some-server.com/some-file.xml';
$simplexmlelement_obj = simplexml_load_file($url);
$array_of_objects_from_xml = array();
if ($simplexmlelement_obj !== false) {
$xml_as_json = json_encode($simplexmlelement_obj);
$array_of_objects_from_xml = json_decode($xml_as_json);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment