Skip to content

Instantly share code, notes, and snippets.

@Kr3m
Forked from BilalBudhani/rssToJson
Created June 25, 2019 01:27
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 Kr3m/d83a36d242e59bd2af1caade5da1e6bc to your computer and use it in GitHub Desktop.
Save Kr3m/d83a36d242e59bd2af1caade5da1e6bc 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