Home  >  Article  >  Backend Development  >  请教如何把一段数据自动分行

请教如何把一段数据自动分行

WBOY
WBOYOriginal
2016-06-13 13:15:321182browse

请问怎么把一段数据自动分行
http://vwvvv.sinaapp.com/kww.php?txt=30/30826/5215401

这段文章的源代码里,文字是分行的,但是直接打开就变成空格了。。

怎么处理才能打开就是分行的??

谢谢了!

------解决方案--------------------

PHP code

$str = file_get_contents("http://vwvvv.sinaapp.com/kww.php?txt=30/30826/5215401");
$str=iconv("gb2312","UTF-8",$str);
echo nl2br($str);
<br><font color="#e78608">------解决方案--------------------</font><br>
明白了,是想让给document.writeln的串不因为换行符而报错吧?<br><br>js的续行符是“\”,你在每个自然行结束处加一个 \ 字符就可以了<br><br>php 代码就是<br>$text = parg_replace("/[\r\n]+/s", '\\n', $text); <div class="clear">
                 
              
              
        
            </div>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn