Skip to content Skip to sidebar Skip to footer

过滤转换后的html、css、js

有时候我们需要过滤一下文本中的特殊字符,如下图:

/**
     * 过滤转换后的html、css、js
     * @param $content
     * @return null|string|string[]
     */
    public function clearHtml($content) {
        $content = preg_replace('/(<).+?(>)/','',$content);
        $content = preg_replace('/(&+)|(nbsp;+)|(”+)|(“+)/','',$content);
        return $content;
    }

过滤后的效果如图所示:

Leave a comment