This article mainly introduces the PHP to remove string newline character examples, the following sorting out the common way to remove the line, the need for friends can refer to the following
The 1th way: Code is as follows: <?php str_replace ("n", ", $str); ?> 2nd: Code as follows: <?php Str_replace ("RN", ", $str); ?> 3rd: Code as follows: <?php preg_replace ("/s/",", $str); ?> Following instructions: First, say n,r,t N soft carriage return: The beginning of the line in Windows that represents a newline and returns to the next line in Linux/unix, but does not return to the beginning of the next line R soft space: in Linux/unix Returns to the beginning of the line at the beginning of the row, indicating the line break in Mac OS and returning to the next line. The equivalent of n in Windows T-jump (move to next column) Supplemental NOTE: They are valid in a string of double quotes or delimiters, and are not valid in a string of single quotes. RN is commonly used to represent the return key on the keyboard (Linux,unix), or only in N (Windwos), in the Mac OS with R to express enter! T represents the newline symbol in the tab file on the keyboard: Windows:n linux/unix:rn The following code explains three common methods for removing line wrapping in the string in PHP 1, using the escape character function code as follows: <?php $str = str_replace (Array ("/r/n", "/R", "N"), ', $str);?> 2, replace code with regular expressions as follows: < ? php $str = preg_replace ('//s*/', ', $str);?> 3, the recommended use of PHP system constants Code is as follows: <?php $str = Str_replace (PH P_eol, ", $str);?>