支付宝赞助帐号:service@kuitao8.com 

php去除html标签函数

Created2017-06-30   Views 454    Author 懒人程序
function noHTML($content){

        $content = preg_replace("/<a[^>]*>/i",'', $content);
        $content = preg_replace("/<\/a>/i", '', $content);
        $content = preg_replace("/<div[^>]*>/i",'', $content);
        $content = preg_replace("/<\/div>/i",'', $content);
        $content = preg_replace("/<font[^>]*>/i",'', $content);
        $content = preg_replace("/<\/font>/i",'', $content);
        $content = preg_replace("/<p[^>]*>/i",'', $content);
        $content = preg_replace("/<\/p>/i",'', $content);
        $content = preg_replace("/<span[^>]*>/i",'', $content);
        $content = preg_replace("/<\/span>/i",'', $content);
        $content = preg_replace("/<\?xml[^>]*>/i",'', $content);
        $content = preg_replace("/<\/\?xml>/i",'', $content);
        $content = preg_replace("/<o:p[^>]*>/i",'', $content);
        $content = preg_replace("/<\/o:p>/i",'', $content);
        $content = preg_replace("/<u[^>]*>/i",'', $content);
        $content = preg_replace("/<\/u>/i",'', $content);
        $content = preg_replace("/<b[^>]*>/i",'', $content);
        $content = preg_replace("/<\/b>/i",'', $content);
        $content = preg_replace("/<meta[^>]*>/i",'', $content);
        $content = preg_replace("/<\/meta>/i",'', $content);
        $content = preg_replace("/<!--[^>]*-->/i",'', $content);
        $content = preg_replace("/<p[^>]*-->/i",'', $content);
        $content = preg_replace("/style=.+?['|\"]/i",'',$content);
        $content = preg_replace("/class=.+?['|\"]/i",'',$content);
        $content = preg_replace("/id=.+?['|\"]/i",'',$content);
        $content = preg_replace("/lang=.+?['|\"]/i",'',$content);
        $content = preg_replace("/width=.+?['|\"]/i",'',$content);
        $content = preg_replace("/height=.+?['|\"]/i",'',$content);
        $content = preg_replace("/border=.+?['|\"]/i",'',$content);
        $content = preg_replace("/face=.+?['|\"]/i",'',$content);
        $content = preg_replace("/face=.+?['|\"]/",'',$content);
        $content = preg_replace("/face=.+?['|\"]/",'',$content);
        $content = str_replace( " ","",$content);
        $content = str_replace( "&nbsp;","",$content);
        return $content;
    }
上一篇: php仅让搜索引擎访问的方法
下一篇: php上传头像检测是不是木马
支持键盘 ← →

邮件订阅

订阅我们的精彩内容