$search = array ("'<script[^>]*?>.*?</script>'si", // 去掉 JavaScript
"'<[\/\!]*?[^<>]*?>'si", // 去掉 HTML 标记
"'([\r\n])[\s]+'",// 去掉空白字符
"'&(quot|#34)'i",// 替换 HTML 实体
"'&(amp|#38)'i",
"'&(lt|#60)'i",
"'&(gt|#62)'i",
"'&(nbsp|#160)'i"
) // 作为 PHP 代码运行
$replace = array ("","","\\1","\"","&","<",">"," ")
$html = preg_replace($search, $replace, $html)
顶
使用正则表达式去掉html标签的方法常用的正则表达式是:/<[^<]+?>/g1、定义含有html标签的字符串:$text='<p>Testparagraph.</p><!--Comment--><ahref="#fragment">Othertext</a>'2、定义正则表达式并替换$val=preg_replace('/<[^<]+?>/g','',$row_get_Business['business_description'])3、截取指定长度$businessDesc=substr(val,0,110)