復制代碼 代碼如下:
<?php
//php 不同系統的換行
//不同系統之間換行的實現是不一樣的
//linux 與unix中用 /n
//MAC 用 /r
//window 為了體現與linux不同 則是 /r/n
//所以在不同平臺上 實現方法就不一樣
//php 有三種方法來解決
//1、使用str_replace 來替換換行
$str = str_replace(array("/r/n", "/r", "/n"), "", $str);
//2、使用正則替換
$str = preg_replace('//s*/', '', $str);
//3、使用php定義好的變量 (建議使用)
$str = str_replace(PHP_EOL, '', $str);
?>
新聞熱點
疑難解答