<?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);
?>
Previous Post
Markdown image 替换为 html标签 Next Post
用了16款考研刷题app,就一两款好用,心好累 blueidea
Recommended Posts
要在原文件名前加上前缀并实现文件的批量重命名,你可以根据你所使用的操作系统选择合适的脚本语言来编写脚本。以下是在不同操作系统上实现这一功能的示例: 在 Windows 上使用 PowerShell 在 macOS/Linux 上使用 Shell 脚本 在 Python 中使用 os 模块 注意事项 将上述脚本中的 folder_path 或 $folderPath 替换为你的文件夹路径,将 prefix 替换为你想要添加的前缀,然后运行脚本即可。