The first type of notation:
$content =str_replace ("\ n", "", $content);
Echo $content;
The second way:
Str_replace ("\ r \ n", "", $str);
The third type of notation:
$content =preg_replace ("/\s/", "", $content);
Echo $content;
Report:
First of all, \n,\r,\t.
\ n Soft return:
Show line breaks in Windows and go back to the beginning of the next line
In Linux, Unix only represents line breaks, but does not go back to the beginning of the next line.
\ r Soft Space:
In Linux, Unix represents the return to the beginning of the line.
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)
A few notes:
They are valid in a double-quote or delimiter-represented string, and are not valid in a single-quote string.
\ r \ n generally used together, used to indicate the key on the keyboard return (Linux,unix), can also be used only \ n (windwos), in Mac OS with \ r to indicate enter!
\ t represents the "tab" key on the keyboard.
Line break symbols in the file:
Windows: \ n
Linux,unix: \ r \ n
Instance code:
Copy CodeThe code is as follows:
PHP line breaks for different systems
The implementation of line breaks between different systems is not the same
Linux and Unix with/n
MAC with/R
Window is/r/n in order to show that it is different from Linux
So the implementation method on different platforms is not the same
PHP has three ways to solve
1. Use Str_replace to replace line breaks
$str = Str_replace (Array ("/r/n", "/R", "/n"), "", $str);
2. Use regular replacement
$str = preg_replace ('//s*/', ' ', $str);
3. Use PHP-defined variables (recommended)
$str = Str_replace (Php_eol, ", $STR);
?>
http://www.bkjia.com/PHPjc/324521.html www.bkjia.com true http://www.bkjia.com/PHPjc/324521.html techarticle The first form of writing : $content =str_replace ("\ n", "", $content); Echo $content; the second: Str_replace ("\ r \ n", "", $str); The Third Way: $content =preg_replace ("/\s/", "", $content); EC ...