Skip to content

Instantly share code, notes, and snippets.

@Nav-Appaiya
Forked from BilalBudhani/rssToJson
Created September 28, 2018 13:15
Show Gist options
  • Save Nav-Appaiya/65803f6f6037e44ff38085bdd31bb26b to your computer and use it in GitHub Desktop.
Save Nav-Appaiya/65803f6f6037e44ff38085bdd31bb26b to your computer and use it in GitHub Desktop.
PHP function to convert simple RSS to JSON
public function Parse ($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