Jump to content

Archived

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

raimis100

clean content for rss feed

Recommended Posts

Hey!

 

I am making my own rss feed generator.

 

So far everything was okey but my feed does not validate because of unwanted chars like line breaks, #, ! and so on. Is there a code you can suggest that cleans up all those chars and leaves only numbers and letters ?

Share this post


Link to post
Share on other sites

Yea i am dumb , I know!

 

This is what I did :P

 


Function IsValid ($data)
{
   $chars[0] = "q"; 
   $chars[1] = "w"; 
   $chars[2] = "e"; 
   $chars[3] = "r"; 
   $chars[4] = "t"; 
   $chars[5] = "y"; 
   $chars[6] = "u"; 
   $chars[7] = "i"; 
   $chars[8] = "o"; 
   $chars[9] = "p"; 
   $chars[10] = "a"; 
   $chars[11] = "s"; 
   $chars[12] = "d"; 
   $chars[13] = "f"; 
   $chars[14] = "g"; 
   $chars[15] = "h"; 
   $chars[16] = "j"; 
   $chars[17] = "k"; 
   $chars[18] = "l"; 
   $chars[19] = "z"; 
   $chars[20] = "x"; 
   $chars[21] = "c"; 
   $chars[22] = "v"; 
   $chars[23] = "b"; 
   $chars[24] = "n"; 
   $chars[25] = "m"; 
   $chars[26] = "1"; 
   $chars[27] = "2"; 
   $chars[28] = "3"; 
   $chars[29] = "4"; 
   $chars[30] = "5"; 
   $chars[31] = "6"; 
   $chars[32] = "7"; 
   $chars[33] = "8"; 
   $chars[34] = "9"; 
   $chars[35] = "0"; 
   $chars[35] = "."; 
   $chars[35] = "!"; 
   $chars[35] = "?"; 
   $chars[35] = " "; 
   $chars[36] = "!"; 
   $chars[37] = "."; 
   $chars[38] = "?"; 
   
   For ($I = 0;$I < count ($chars) ; $I++ ) {
     If (strtolower($data) == $chars[$I])
     {
       return true;
       break;
     }
   }
}

  Function CleanFeeds ($data)
  {
    for ($I = 0;$I < strlen ($data) ; $I++ ) {
    	$string = substr ($data, $I, 1);
    	If (IsValid ($string) == true)
    	{
        $all = $all . $string;
      }
    }
    return $all;
  }

 

I did it in hard way but atleast it works :P

 

And ye a, thanks for help guys :D

Share this post


Link to post
Share on other sites

×
×
  • 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.