PHP在不同的系统中,换行是不同的
Linux:\n
Windows:\r\n
mac:\r
所以去除回车换行的方法:
1.使用php定义好的变量(比较好的方法,推荐)
$str= str_replace(PHP_EOL, '', $str);
2.使用str_replace 来替换换行
$str= str_replace(array("\r\n", "\r", "\n"), "", $str);
本文共 200 字,大约阅读时间需要 1 分钟。
PHP在不同的系统中,换行是不同的
Linux:\n
Windows:\r\n
mac:\r
所以去除回车换行的方法:
1.使用php定义好的变量(比较好的方法,推荐)
$str= str_replace(PHP_EOL, '', $str);
2.使用str_replace 来替换换行
$str= str_replace(array("\r\n", "\r", "\n"), "", $str);
转载地址:http://fdlml.baihongyu.com/