XMPP JavaScript Library READ MORE

PHP function to clean text for RSS Feed

PHP, Sachin Puri, 2013-03-14 00:14:43

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=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
    return $content;


Add Your Comment
    Yes! I want to receive all comments by email

  by Raj on 26-Jul-2014 03:17 pm
  • Reply
  •  2 Like
  •  2 Dislike
  • Report
  by andy on 25-Feb-2014 12:35 am
This is awesome dude, thanks so much
  • Reply
  •  2 Like
  •  2 Dislike
  • Report
  by Rajiv on 13-Jul-2013 12:36 am
Thanks for the help
  • Reply
  •  10 Like
  •  2 Dislike
  • Report