The 1th type of notation:
Copy CodeThe code is as follows:
Str_replace ("n", "', $str);
?>
The 2nd type of notation:
Copy the Code code as follows:
Str_replace ("RN", ", $str);
?>
The 3rd type of notation:
Copy the Code code as follows:
Preg_replace ("/s/", ", $str);
?>
The following instructions:
First of all, n,r,t.
N Soft return:
Show line breaks in Windows and go back to the beginning of the next line
The Linux/unix only represents a newline, but does not go back to the beginning of the next line
R Soft Space:
Returns to the beginning of the line in Linux/unix
Represents a newline in Mac OS and returns to the beginning of the next line, equivalent to the effect of N in Windows
T-jump (move to next column)
Additional notes:
They are valid in a double-quote or delimiter-represented string, and are not valid in a single-quote string.
RN is generally used together to indicate the return key on the keyboard (Linux,unix), or only n (windwos), in Mac OS with R to indicate carriage returns!
T means the TAB key on the keyboard
Line break symbols in the file:
Windows:n
Linux/unix:rn
The following code illustrates the three common methods of removing line breaks in a string in PHP
1. Use the escape character function
Copy the Code code as follows:
$str = Str_replace (Array ("/r/n", "/R", "/n"), "", $str);
?>
2. Replace with regular expression
Copy the Code code as follows:
$str = preg_replace ('//s*/', ' ', $str);
?>
3, the recommended use of PHP system constants
Copy the Code code as follows:
$str = Str_replace (Php_eol, ", $STR);
?>
http://www.bkjia.com/PHPjc/735240.html www.bkjia.com true http://www.bkjia.com/PHPjc/735240.html techarticle The 1th type: Copy code code as follows: PHP str_replace ("n", "', $str);? 2nd: Copy the code as follows: PHP str_replace (" rn "," ', $str);? 3rd type: Copy code ...