php删除换行的方法:1、使用str_replace来替换换行 ,代码为【$str = str_replace(array())】;2、使用正则替换 ,代码为【$str = preg_replace('//s*/', '', $str)】。

php删除换行的方法:
php 不同系统的换行
不同系统之间换行的实现是不一样的
linux 与unix中用 \n
立即学习“PHP免费学习笔记(深入)”;
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);
相关学习推荐:php编程(视频)
以上就是php如何删除换行的详细内容,更多请关注php中文网其它相关文章!
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号