您的位置:首页 > 编程语言 > PHP开发

php去除html

2014-02-20 16:15 176 查看
代码如下

//清除html
function clearhtml($str){
$str = trim($str);
$str = strip_tags($str,"");
$str=strip_tags($str,"");//利用php自带的函数清除html格式
$str=preg_replace("/\t/","",$str);//使用正则表达式匹配需要替换的内容,如空格和换行,并将替换为空
$str=preg_replace("/\r\n/","",$str);
$str=preg_replace("/\r/","",$str);
$str=preg_replace("/\n/","",$str);
$str=preg_replace("/ /","",$str);//匹配html中的空格
$str=preg_replace("/ /","",$str);//匹配html中的空格
return trim($str);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: