如何用 | 替换新行?
假设我有这些:
$strPar = "12345|12345|12345|12345
12345|12345|12345|12345
12345|12345|12345|12345";
我希望它是这样的:
$strPar = "12345|12345|12345|12345|12345|12345|12345|12345|12345|12345|12345|12345";
如何用 | 替换新行?
假设我有这些:
$strPar = "12345|12345|12345|12345
12345|12345|12345|12345
12345|12345|12345|12345";
我希望它是这样的:
$strPar = "12345|12345|12345|12345|12345|12345|12345|12345|12345|12345|12345|12345";
您可以使用:
$strPar = "12345|12345|12345|12345
12345|12345|12345|12345
12345|12345|12345|12345";
$strpar = str_replace("\n", "|", $strPar);
确保\n
字符在双引号中
$string = str_replace("\n", "|", $string);
$string = str_replace("\r", "|", $string);