Home  >  Article  >  Backend Development  >  换行符空格替换难题解决办法

换行符空格替换难题解决办法

WBOY
WBOYOriginal
2016-06-13 10:09:23978browse

换行符空格替换难题
我要把空格换成 

换行符换成


疑惑:
替换的时候 空格 写"" 还是\s

换行符是\n 还是\r\n

环境是是在非IR系列浏览器中

ie浏览器不用考虑。

求解写法,一次性全部替换。

设内容为$txt

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

PHP code
echo preg_replace(array('/ /','/[\r\n]+/'), array(' ','<br>'), $string);<br><font color="#e78608">------解决方案--------------------</font><br>$changeset = array('\r\n'=>'<br>',' '=>'$nbsp;');<br>$str = strtr($str,$changeset);<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