/* +---------------------------------------------------------- * 去掉html中的空格和换行的方法 +---------------------------------------------------------- */ function delhtml($str) { $str = trim($str); //清除字符串两边的空格 $str = strip_tags($str,""); //利用php自带的函数清除html格式 $str = preg_replace("/ /","",$str); //使用正则表达式替换内容,如:空格,换行,并将替换为空。 $str = preg_replace("/ /","",$str); $str = preg_replace("/ /","",$str); $str = preg_replace("/ /","",$str); $str = preg_replace("/ /","",$str); $str = preg_replace("/ /","",$str); //匹配html中的空格 $str = preg_replace('# #','',$str); $str = preg_replace('/s+/u', '',$str); $str = preg_replace("/[sv".chr(163).chr(160)."]+$/","",$str); $str = str_replace(array(" "," "," "," "," "," "), '', $str); $str = str_replace(chr(194) . chr(160), "-", $str); return trim($str); //返回字符串 }
可以去掉word导入的内容中的空格喔。