Created
April 9, 2015 20:04
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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