Forum Moderators: coopster
// Remove js, HTML tags, and white space.
$search = array ("'<script[^>]*?>.*?</script>'si", "'<[\/\!]*?[^<>]*?>'si", "'([\r\n])[\s]+'");
$replace = array ("", "", "\\1");
$mytext = preg_replace($search, $replace, $mytext);
It works perfectly, but I would like to allow the user to use a break tag: <br /> without it being removed - is there a way, without completely throwing out the above?
Eg:
$text = str_replace('¬', '', $text); //remove char from user text
$text = str_replace('<br />', '¬', $text); //replace break tags with funny character
...your regex code here...
$text = str_replace('¬', '<br />', $text); //now restore break tags