去除文本中的html標籤

function trimHtml($str, $allow = '')
{
    $str = str_replace(PHP_EOL, '', $str);
    $str = str_replace('<br />' , "\n", $str);
    $str = strip_tags($str, $allow);
    $str = str_replace(' ' , '', $str);
    $str = str_replace('&nbsp;' , ' ', $str);
    $str = str_replace(array("\r\n", "\r", "\n"), "", $str);//去除回車換行符
    return $str;
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章