-
-
Save raihan-uddin/556028f76c7d892c3ccbc16b64e48017 to your computer and use it in GitHub Desktop.
PHP : XML TO JSON
This file contains 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
$fileContents = file_get_contents('http://webdevelopergeeks.com/demo/sms.xml'); | |
$fileContents = str_replace(array("\n", "\r", "\t"), '', $fileContents); | |
$fileContents = trim(str_replace('"', "'", $fileContents)); | |
$simpleXml = simplexml_load_string($fileContents); | |
$json = json_encode($simpleXml); | |
return $json; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment