/ Published in: PHP
                    
                                        
strip_tags is a default HTML Tag stripper in PHP. However, it can't strip some of the tags, so this enhanced version called strip_html_tags will remove more html elements.
                
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
function strip_html_tags( $text )
{
// Remove invisible content
'@<head[^>]*?>.*?</head>@siu',
'@<style[^>]*?>.*?</style>@siu',
'@<script[^>]*?.*?</script>@siu',
'@<object[^>]*?.*?</object>@siu',
'@<embed[^>]*?.*?</embed>@siu',
'@<applet[^>]*?.*?</applet>@siu',
'@<noframes[^>]*?.*?</noframes>@siu',
'@<noscript[^>]*?.*?</noscript>@siu',
'@<noembed[^>]*?.*?</noembed>@siu',
// Add line breaks before and after blocks
'@</?((address)|(blockquote)|(center)|(del))@iu',
'@</?((div)|(h[1-9])|(ins)|(isindex)|(p)|(pre))@iu',
'@</?((dir)|(dl)|(dt)|(dd)|(li)|(menu)|(ol)|(ul))@iu',
'@</?((table)|(th)|(td)|(caption))@iu',
'@</?((form)|(button)|(fieldset)|(legend)|(input))@iu',
'@</?((label)|(select)|(optgroup)|(option)|(textarea))@iu',
'@</?((frameset)|(frame)|(iframe))@iu',
),
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
"
$0", "
$0", "
$0", "
$0", "
$0", "
$0",
"
$0", "
$0",
),
$text );
// you can exclude some html tags here, in this case B and A tags
}
Comments
 Subscribe to comments
                    Subscribe to comments
                
                