slider2015
-
Posts
1 -
Joined
-
Last visited
Never
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.
Page Level RSS filter by Keyword
in PHP Coding Help
Posted
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
);
}
}