Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

filter Rss/atom feeds (need help)

Status
Not open for further replies.

mygmat123

Technical User
Jun 28, 2004
56
US
I'm looking for a rss/atom filter which I can use to set criteria for the rss I list on my site.

for example: I have a rss news feed, I would like to use a url with critera that I can then use to filter the newsfeed.

example url


so if you want all items with the words "hello and "goodbye", but not the word "stupid" you would add
title=hello+goodbye-stupid to the url(like above).

The same would be for <link>, <description>, etc.

<item>
<title>hello</title>
<link> <description>this is a sample</description>
</item>


Does any one now how to do this. I'm a novice at php and have not clue. But I'm been trying to learn, and still can not figure it out.
 
Well, first you would need to use a "+" before the first "hello" so you know if you want the first word or not, like:

title=+hello+goodbye-stupid

Second, it's much easier if you separate each word, like this:

title=+hello|+goodbye|-stupid

That way, you can explode($_GET['title'],"|") and have a array with the "search" fields. Then you just have to check if the first char of the array is a "+" or a "-", and then process the word.

Something like this:
Code:
$criteria = $_GET['title'];
$vars = explode($criteria, "|");
for ($i = 0; $i <= count(vars)-1; $i++){
  if (substr($vars[$i],0,1) == "+") { // we have a +, search!
  }
  if (substr($vars[$i],0,1) == "-") { // we have a -
  }
// don't use *else* because there can be errors in the var, this way only vars starting with + or - get used

}

jamesp0tter,
mr.jamespotter@gmail.com

p.s.: sorry for my (sometimes) bad english :p
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top