-6

如何用 | 替换新行?

假设我有这些:

$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";
4

2 回答 2

5

您可以使用:

$strPar = "12345|12345|12345|12345
    12345|12345|12345|12345
    12345|12345|12345|12345";

$strpar = str_replace("\n", "|", $strPar);

确保\n字符在双引号中

于 2013-05-31T07:48:15.807 回答
-1
$string = str_replace("\n", "|", $string);
$string = str_replace("\r", "|", $string);
于 2013-05-31T07:48:34.883 回答