HTML 转 TXT PHP 函数

这个函数我没试过 不知道好不好用

 

function htmltotxt($document){
    $search = array('@<script[^>]*?>.*?</script>@si',  // Strip out javascript
                   '@<[\\/\\!]*?[^<>]*?>@si',            // Strip out HTML tags
                   '@<style[^>]*?>.*?</style>@siU',    // Strip style tags properly
                   '@<![\\s\\S]*?--[ \\t\\n\\r]*>@'          // Strip multi-line comments including CDATA 
    );
    $text = preg_replace($search, '', $document);
    return $text;
}

 

posted on 2020-06-22 14:07  吉格斯  阅读(202)  评论(0编辑  收藏  举报

导航