PHP删除HTMl标签

 /**
 * 取出html标签
 * 
 * @access public
 * @param string str
 * @return string
 * 
 */
function deletehtml($str) {
    $str = trim($str); //清除字符串两边的空格
    $str = strip_tags($str,"<p>"); //利用php自带的函数清除html格式。保留P标签
    $str = preg_replace("/	/","",$str); //使用正则表达式匹配需要替换的内容,如:空格,换行,并将替换为空。
    $str = preg_replace("/
/","",$str); 
    $str = preg_replace("/
/","",$str); 
    $str = preg_replace("/
/","",$str); 
    $str = preg_replace("/ /","",$str);
    $str = preg_replace("/&nbsp; /","",$str);  //匹配html中的空格
    return trim($str); //返回字符串
}
原文地址:https://www.cnblogs.com/kevin0709/p/3158213.html