The other day I was about to integrate an RSS feed onto a web page using jQuery.

To ease the way in which jQuery accessed the feed, I decided to write a quick fopen proxy, and then I figured… hey, why not convert this to JSON while I’m at it?

I did a quick search for “convert rss to json with php”, and turned up a bunch of stuff that wasn’t what I was looking for. So I opted out of the lazy web approach and decided to think for a moment… aha, this is much easier!

$json = json_encode(simplexml_load_string($rss));

Wow. Who says you can’t do useful stuff with PHP in one single line??