$text=ereg_replace(" (?:\W)"," ",$text);

解决方案 »

  1.   

    $text=ereg_replace(" "," nbsp;",,$text);
    注意这里后面的空格是特殊性字符是双字节的,支持换行...
      

  2.   

    $str=preg_replace("/<br>/i","",$str);
    $str=stripslashes($str);
    $str=str_replace('<','&lt;',$str);
    $str=str_replace('>','&gt;',$str);
    $str=str_replace(" ","&nbsp;",$str);
    $str=str_replace("\r","<BR>",$str);
    $str=preg_replace("/\s/","&nbsp;&nbsp;&nbsp;&nbsp;",$str);用上面的就行了。 ╔════════════╗╔════════════╗
    ║⊙⊙中国项目交易在线⊙⊙║║⊙⊙生活情感世界社区⊙⊙║
    ║  http://www.pc80.com   ║║ http://love.pc80.com   ║
    ╚════════════╝╚════════════╝
      

  3.   

    这问题的解决方法是
    function text_dowith($text)
    {
       $text=htmlspecialchars($text);
       $text=ereg_replace("\n","<br/>",$text);
       $text=ereg_replace("  ","&nbsp;&nbsp;",$text);
       $text=addslashes($text);
       return $text;
    }
    自己搞定。