A small RSS filter written in PHP

Nearly all news sources has some posts I’m not interested in. I can’t believe no RSS readers has implemented good enough filters yet. But I anyway I wrote my own. :) I don’t think my server can handle too much usage, so I’m just giving you the code as is.

edit: The code is now on GitHub!

Install to a PHP5 server and use like this (fictional example):


The script returns a RSS feed with only entries in one of the chosen categories. It does no caching or header support, so it uses much more resources than necessary. That’s why I don’t tell where my personal installation is. :)

  • slee

    hello, i found your page by googling ‘rss filter’…this is similar to what i’m trying to accomplish.

    i’m trying to remove certain items from the rss(xml) by keyword so i can use:


    here is my latest attempt on it:
    $pg = preg_replace('#.*?Great.*?#s’, ”, $pg);
    echo $pg;

    where it removes an ‘*great* from my $pg xml content
    any help would be greatly appreciated


  • slee

    ugh, posting the php code in comments stripeed out the tags, let me try and re explain..i’m downloading an rss feed, it has multiple ‘entry’ tags seperating each item of news, i’m wanting to remove each ‘entry’ if it contains a keyword anywhere in the $pg

    thanks again

  • Using preg_replace on an XML document is begging for trouble. I think you need to use simplexml_load_file() like I do and parse the XML properly.