Advertisement
Guest User

Untitled

a guest
Jun 4th, 2010
388
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.33 KB | None | 0 0
  1. function strip_html_tags( $text )
  2. {
  3.     $text = preg_replace(
  4.             array(
  5.                 // Remove BBCode tags
  6.                     '@[[\/\!]*?[^\[\]]*?]@siu',
  7.                 // Remove invisible content
  8.                     '@<head[^>]*?>.*?</head>@siu',
  9.                     '@<style[^>]*?>.*?</style>@siu',
  10.                     '@<script[^>]*?.*?</script>@siu',
  11.                     '@<object[^>]*?.*?</object>@siu',
  12.                     '@<embed[^>]*?.*?</embed>@siu',
  13.                     '@<applet[^>]*?.*?</applet>@siu',
  14.                     '@<noframes[^>]*?.*?</noframes>@siu',
  15.                     '@<noscript[^>]*?.*?</noscript>@siu',
  16.                     '@<noembed[^>]*?.*?</noembed>@siu',
  17.                 // Add line breaks before and after blocks
  18.                     '@</?((address)|(blockquote)|(center)|(del))@iu',
  19.                     '@</?((div)|(h[1-9])|(ins)|(isindex)|(p)|(pre))@iu',
  20.                     '@</?((dir)|(dl)|(dt)|(dd)|(li)|(menu)|(ol)|(ul))@iu',
  21.                     '@</?((table)|(th)|(td)|(caption))@iu',
  22.                     '@</?((form)|(button)|(fieldset)|(legend)|(input))@iu',
  23.                     '@</?((label)|(select)|(optgroup)|(option)|(textarea))@iu',
  24.                     '@</?((frameset)|(frame)|(iframe))@iu',
  25.             ),
  26.             array(
  27.                     ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
  28.                     "\n\$0", "\n\$0", "\n\$0", "\n\$0", "\n\$0", "\n\$0",
  29.                     "\n\$0", "\n\$0",
  30.             ),
  31.             $text );
  32.     $text = strip_tags( $text );
  33.     $text = nl2br($text);
  34.     return $text ;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement