raimis100 Posted September 23, 2008 Share Posted September 23, 2008 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 ? Quote Link to comment Share on other sites More sharing options...
raimis100 Posted September 23, 2008 Author Share Posted September 23, 2008 Yea i am dumb , I know! This is what I did 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 And ye a, thanks for help guys Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.