Use for text editor like TinyMce content. Remove html tags from string, best use for META tags.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | function stripAlpha($item) { $search = array( '@<script[^>]*?>.*?</script>@si' // Strip out javascript , '@<style[^>]*?>.*?</style>@siU' // Strip style tags properly , '@<[\/\!]*?[^<>]*?>@si' // Strip out HTML tags , '@<![\s\S]*?–[ \t\n\r]*>@' // Strip multi-line comments including CDATA , '/\s{2,}/', '/(\s){2,}/' ); $pattern = array( '#[^a-zA-Z ]#' // Non alpha characters , '/\s+/' // More than one whitespace ); $replace = array( '', ' ' ); $item = preg_replace($search, '', html_entity_decode($item)); $item = trim(preg_replace($pattern, $replace, strip_tags($item))); return $item; } |
Useful for Meta Tag description etd