Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function html2txt($text) {
- $search = array('@<script[^>]*?>.*?</script>@si', // Strip out javascript
- '@<[\/\!]*?[^<>]*?>@si', // Strip out HTML tags
- '@<style[^>]*?>.*?</style>@siU', // Strip style tags properly
- '@<![\s\S]*?--[ \t\n\r]*>@' // Strip multi-line comments including CDATA
- );
- $replace_array = array(';', '|#|', '{#}', "{}", "'", "\\", '#');
- $text = trim($text);
- $text = preg_replace($search, '', $text);
- $text = str_replace($replace_array, "", $text);
- $text = htmlspecialchars($text, ENT_COMPAT, 'UTF-8');
- $text = strip_tags($text);
- return $text;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement