#4 jake
用php自带的strip_tags函数来过滤内容,Google一下
2013-05-14 23:48:59
#5 sunxch100
我给个例子:$str = strip_tags('html内容');
抄来的,参考一下:
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
'@]*?>.*?@siu',
'@@siu',
'@@siu',
'@
@siu',
'@
@siu',
'@
@siu',
'@
]*?.*?@siu',
'@
@siu',
'@
]*?.*?@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 , '
' );
}
2013-05-31 16:27:05