PHP中替换换行符方法总结
<?php header("content-type:text/html;charset=utf-8"); $str = "aaaa bbbb cccc dddd"; echo $str; echo '<br/>'; echo nl2br($str); echo '<br/>'; $str_a = str_replace(array("\r\n","\r","\n"),"",$str); echo $str_a; echo '<br/>'; $str_b = str_replace(PHP_EOL,"",$str); echo $str_b; echo '<br/>'; $str_c = preg_replace('/\s*/','',$str); echo $str_c; echo '<br/>'; ?>
起点在哪,或许选择不了。重要的是,你追求的终点在哪!