Skip to content

Instantly share code, notes, and snippets.

@menjilx
Forked from BilalBudhani/rssToJson
Created August 7, 2021 13:03
Show Gist options
  • Save menjilx/a2807d4c1f45258597638d8d71781192 to your computer and use it in GitHub Desktop.
Save menjilx/a2807d4c1f45258597638d8d71781192 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