The 1th way:
Copy Code code as follows:
<?php
Str_replace ("n", ", $str);
?>
The 2nd way:
Copy Code code as follows:
<?php
Str_replace ("RN", ", $str);
?>
The 3rd way:
Copy Code code as follows:
<?php
Preg_replace ("/s/", "", $str);
?>
Here is a description:
First, n,r,t.
N Soft return:
Represents a newline in windows and returns to the beginning of the next line
Only wrap in Linux/unix, but not back to start of next line
R Soft Space:
In Linux/unix to return to the beginning of the row
The first position in the Mac OS that represents a newline and returns to the next line, equivalent to the effect of N in Windows
T-jump (move to next column)
Supplementary Note:
They are valid in double quotes or in a string represented by a delimiter, 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 TAB key on the keyboard
NewLine symbol in File:
Windows:n
Linux/unix:rn
Here's a code description of three common ways to remove line wrapping in a string in PHP
1. Use the escape character function
Copy Code code as follows:
<?php
$str = Str_replace (Array ("/r/n", "/R", "N"), ", $STR);
?>
2. Use regular expressions to replace
Copy Code code as follows:
<?php
$str = preg_replace ('//s*/', ', ', $str);
?>
3, the recommended use of PHP system constants
Copy Code code as follows:
<?php
$str = Str_replace (Php_eol, ', $str);
?>