PHP去除Html所有标签、空格以及空白,style标签以及script标签

2018-02-01 15:43:02

根据正则去掉自己不想要的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);
}


  • 2020-02-19 23:26:58

    php array_pop 删除数组最后一个元素实例

    php array_pop函数将数组最后一个单元弹出(出栈),即删除数组的最后一个元素。本文章通过php实例向大家讲解array_pop函数的使用方法。

  • 2020-02-20 18:35:21

    Vue加载组件、动态加载组件的几种方式

    组件是Vue.js最强大的功能之一。组件可以扩展HTML元素,封装可重用的代码。在较高层面上,组件是自定义的元素,Vue.js的编译器为它添加特殊功能。在有些情况下,组件也可以是原生HTML元素的形式,以is特性扩展。