Cleaning text for RSS feed is common problem for any web developer. I have created this function to clean all the special characters from text to include in RSS Feed, this function is working for me.
Just take care of $find variable and keep including all the special characters which are breaking the code.
function clean($content){ $find=array("’","“","”"); //special characters other then characters starting with & and ending with ; $content=htmlspecialchars_decode($content); $content=strip_tags($content); $content=str_replace($find,"",$content); $content=preg_replace('/\&.*\;/','',$content); //Replace all words starting with & and ending with ; with '' $content=preg_replace("/(\r?\n){2,}/",'', $content); //Replace all newline characters with '' $content=preg_replace( "/\s+/", " ", $content );//Replace multiple spaces with single space $content=trim($content); return $content; }