自己编写一个函数,当输出指定字符数时输出<br>

解决方案 »

  1.   

    function WriteReplace($S,$Html) {
        $S=str_replace("\\\\", "\", $S);   if($Html!=1){
         $S=str_replace("<","&lt;",$S);
         $S=str_replace(">", "&gt;",$S);
    $S=str_replace("\n","<br>",$S);
       }
    return($S);
    }
    $text=WriteReplace($title,0);
      

  2.   

    为什么从库里凋出来就不能换行了?mysql
      

  3.   

    调出来后再用函数不就ok了?
    function WriteReplace($S,$Html) {
        $S=str_replace("\\\\", "\", $S);   if($Html!=1){
         $S=str_replace("&lt;","<",$S);
         $S=str_replace("&gt;", ">",$S);
    $S=str_replace("<br>","\n",$S);
       }
    return($S);
    }
    $text=WriteReplace($title,0);
      

  4.   

    在textfield里输入一定文字后自动换行,但插到库里面时肯定没有<br>,所以发表出来时没有换行
      

  5.   

    nl2br(string);
    可以让保存在数据库前换行的输出时也换行!