php去除html标签及空格回车

/**
 * 去除html标签和空格回车等
 * @param $string
 * @return string
 */
function cutstr_html($string){

    $string = strip_tags($string);

    $string = trim($string);

    $string = str_replace(["\t", "\r\n", "\r", "\n", " "], '', $string);

    $string = preg_replace('/\s+|\t+/u', '', $string);
    return $string;

}

以上仅是目前所用

你可能感兴趣的:(php去除html标签及空格回车)