note 107390 added to function.strip-tags
| From: | matthew at poleposition dot uk dot com | Date: | Mon, 06 Feb 2012 13:15:30 +0000 |
| Subject: | note 107390 added to function.strip-tags | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-185869@lists.php.net to get a copy of this message | ||
Here is a far better function for the atypical process of stripping tags:
function strip_html_tags( $text )
{
$text = preg_replace(
array(
// 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',
),
array(
' ', ' ', ' ', ' ', ' ', '
', ' ', ' ', ' ',"$0", "$0", "$0",
"$0", "$0", "$0","$0", "$0",), $text );
return strip_html_tags( $text , '<b><a>' );
}
----
Server IP: 69.147.83.197
Probable Submitter: 98.98.146.38
----
Manual Page -- http://www.php.net/manual/en/function.strip-tags.php
Edit -- https://master.php.net/note/edit/107390
Del: integrated -- https://master.php.net/note/delete/107390/integrated
Del: useless -- https://master.php.net/note/delete/107390/useless
Del: bad code -- https://master.php.net/note/delete/107390/bad+code
Del: spam -- https://master.php.net/note/delete/107390/spam
Del: non-english -- https://master.php.net/note/delete/107390/non-english
Del: in docs -- https://master.php.net/note/delete/107390/in+docs
Del: other reasons-- https://master.php.net/note/delete/107390
Reject -- https://master.php.net/note/reject/107390
Search -- https://master.php.net/manage/user-notes.php