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

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

WBOY
Release: 2016-06-13 13:15:32
Original
1220 people have browsed it

请问怎么把一段数据自动分行
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>
Copy after login
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template