Skip to content

Instantly share code, notes, and snippets.

@djekl
Created March 23, 2013 16:34
Show Gist options
  • Save djekl/5228332 to your computer and use it in GitHub Desktop.
Save djekl/5228332 to your computer and use it in GitHub Desktop.
xml2json
function xml2json($url)
{
$fileContents= file_get_contents($url);
$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