then replace("<br>","&nbsp;&nbsp;&nbsp;&nbsp;<br>")

解决方案 »

  1.   

    输入时以回车键分段,段首有不少于两个空格
    输出时,设$text为输出内容
    $text = eregi_replace("\n +","<p>&nbsp;&nbsp;&nbsp;&nbsp;",$text);
      

  2.   

    我还是看不懂啊,上面讲的代码直接输入到数据库里,不行啊,还是不能显示空两格啊
    我就是用 
    insert to tablename values(一大串新闻内容),但是php编译后,就是排得格式不好看。能否详细一点交交我,分不够继续加。
      

  3.   

    写进入的内容不是HTML格式的,所以排版很难看的,
    写进入之前或者读出之后转换成HTML格式的就行了。
    $contents = str_replace("<","&lt;",$contents);
    $contents = str_replace(">","&gt;",$contents);
    $contents = str_replace(" ","&nbsp;",$contents);
    $contents = str_replace("\t","&nbsp;&nbsp;&nbsp;&nbsp;",$contents);
    $contents = str_replace("\r","<br>",$contents);
      

  4.   

    我还是看不懂str_replace,什么意思,&lt &gt &nbsp分别表示什么意思
      

  5.   

    HTML解决方案:
    <p style="text-indent: 4; margin-top: 1">内容</p>text-indent: 4 是说段落首行缩进4字(就是4个空格)
    margin-top: 1  是说段落前空一行
      

  6.   

    补充一点:
    建议使用两个全角空格,而不是四个&nbsp;
      

  7.   

    nl2br() 这个函数有问题,中国人不要用,如果是全英文就很好