如何编写一个PHP函数来彻底清除HTML标签?
- 内容介绍
- 文章标签
- 相关推荐
本文共计191个文字,预计阅读时间需要1分钟。
php分享一个PHP清除HTML标签的函数,用于去除不必要的HTML格式:
function strip__tags($text) { $text=preg_replace('//', '', $text); $text=preg_replace('/.*?/', '', $text); $text=preg_replace('/.*?/', '', $text); return $text;}
分享一个php清除html标签的函数,用于清除不需要的html标签格式
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 ); }
本文共计191个文字,预计阅读时间需要1分钟。
php分享一个PHP清除HTML标签的函数,用于去除不必要的HTML格式:
function strip__tags($text) { $text=preg_replace('//', '', $text); $text=preg_replace('/.*?/', '', $text); $text=preg_replace('/.*?/', '', $text); return $text;}
分享一个php清除html标签的函数,用于清除不需要的html标签格式
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 ); }

