//去除HTML标记function NoHTML($string){ $string = preg_replace("'<script[^>]*?>.*?</script>'si", "", $string);//去掉javascript $string = preg_replace("'<[///!]*?[^<>]*?>'si", "", $string); //去掉HTML标记 $string = preg_replace("'([/r/n])[/s]+'", "", $string); //去掉空白字符 $string = mb_ereg_replace('^( | )+', '', $string); $string = mb_ereg_replace('( | )+$', '', $string); $string = preg_replace("'&(quot|#34);'i", "", $string); //替换HTML实体 $string = preg_replace("'&(amp|#38);'i", "", $string); $string = preg_replace("'&(lt|#60);'i", "", $string); $string = preg_replace("'&(gt|#62);'i", "", $string); $string = preg_replace("'&(nbsp|#160);'i", "", $string); return $string;}
|