Jump to content

Page Level RSS filter by Keyword


slider2015

Recommended Posts

I am desperatly seeking some help.

 

I want to build a page that pulls in feeds from 3 different sites, but i would like them to be filtered by some keywords.

 

I'm not entirely sure about the best way to do this. If there's any one who knows about Magpie, and how to incorporate this feature, that would be great.

 

Curretnly in my magpie rss fetch script I have:

 

$keywords  = array ("keyword1","keyword2","keyword3")

 

function has_keyword($haystack, $wordlist)

{

  $found = false;

  foreach ($wordlist as $w)

  {

    if (stripos($w, $haystack) !== 0)

    {

      $found = true;

    }

  }

  return $found;

}

 

$rss = simplexml_load_file("http://www.mywebsite.com/my/rss/feed/");

foreach ($rss->channel->item as $i)

{

  if (

      has_keywords($i->title, $keywords)

  || has_keywords($i->description, $keywords)

  || has_keywords($i->category)

  )

  {

    $news[] = array

    (

        "title" => $i->title,

        "description" => $i->description,

        "link" => $i->link

    );

  }

}

Link to comment
https://forums.phpfreaks.com/topic/231292-page-level-rss-filter-by-keyword/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.