根据正则去掉自己不想要的html代码,看下面代码理解意思。
function cutstr_html($string){ $string = preg_replace('#<script[^>]*?>.*?</script>#si','',$string); $string = preg_replace('#<style[^>]*?>.*?</style>#si','',$string); $string = strip_tags($string); $string = trim($string); $string = str_replace("\t","",$string); $string = str_replace("\r\n","",$string); $string = str_replace("\r","",$string); $string = str_replace("\n","",$string); $string = str_replace(" ","",$string); return trim($string); }