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

笔者在前几天做微信自定义分享网页的时候,自定义内容的时候需要去除内容的标签并截取部分内容作为简介便用到了下面了的函数,现在笔者把他分享出来,希望能够帮到大家

function cutstr_html($string, $sublen)    
 {
      $string = strip_tags($string);
      $string = trim($string);
      $string = ereg_replace("t","",$string);
      $string = ereg_replace("rn","",$string);
      $string = ereg_replace("r","",$string);
      $string = ereg_replace("n","",$string);
      $string = ereg_replace("    ","",$string);
      return trim($string);
}