A small RSS filter written in PHP (copy)

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.


$xml =  simplexml_load_file($_GET['input']);

$ix = 0;
while ($ix < count($xml->channel->item) ) {
  if (!array_in_array($xml->channel->item[$ix]->category,$_GET['categories'])) {
  } else {

echo $xml->asXML();

// in_array that accepts two arrays (and returns true if it finds any common value)
function array_in_array($a, $b) {
  if (!is_array($a))
    return in_array($a, $b);

  foreach ($a as $elem) {
    if (in_array($elem, $b))
      return true;
  return false;


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. :)

Comments are closed.