php清除字符串中HTML代码、空格、回车换行符
function DeleteHtml($str) { $str = trim($str); $str = strip_tags($str,""); $str = ereg_replace("\t","",$str); $str = ereg_replace("\r\n","",$str); $str = ereg_replace("\r","",$str); $str = ereg_replace("\n","",$str); $str = ereg_replace(" "," ",$str); return trim($str); }
通过以上代码可以清除HTML代码、空格、回车换行符的函数,根据自己需要可以扩充。