How to remove carriage returns from a string in PHP?
In PHP, to remove line breaks and carriage returns from a string, one can use the str_replace function:
// Remove new line
$string = str_replace("\n", '', $string);
// Remove carriage returns
$string = str_replace("\r", '', $string);
The operation can be done in a single line:// Remove new line and carriage return
$string = str_replace(array("\r", "\n"), '', $string);
See also:
- How to replace carriage returns by spaces in a string in PHP?
- How to remove tabulations in a string in PHP?
In PHP, to remove line breaks and carriage returns from a string, one can use the str_replace function:
// Remove new line
$string = str_replace("\n", '', $string);
// Remove carriage returns
$string = str_replace("\r", '', $string);
The operation can be done in a single line:// Remove new line and carriage return
$string = str_replace(array("\r", "\n"), '', $string);
See also:
- How to replace carriage returns by spaces in a string in PHP?
- How to remove tabulations in a string in PHP?
In PHP, to remove line breaks and carriage returns from a string, one can use the str_replace function:
// Remove new line
$string = str_replace("\n", '', $string);
// Remove carriage returns
$string = str_replace("\r", '', $string);
The operation can be done in a single line:// Remove new line and carriage return
$string = str_replace(array("\r", "\n"), '', $string);
See also:
- How to replace carriage returns by spaces in a string in PHP?
- How to remove tabulations in a string in PHP?
In PHP, to remove line breaks and carriage returns from a string, one can use the str_replace function:
// Remove new line
$string = str_replace("\n", '', $string);
// Remove carriage returns
$string = str_replace("\r", '', $string);
The operation can be done in a single line:// Remove new line and carriage return
$string = str_replace(array("\r", "\n"), '', $string);
See also:
- Comment remplacer les retours chariot par des espaces dans une chaîne de caractères en PHP ?
- Comment remplacer les tabulations par des espaces dans une chaîne de caractères en PHP ?
In PHP, to remove line breaks and carriage returns from a string, one can use the str_replace function:
// Remove new line
$string = str_replace("\n", '', $string);
// Remove carriage returns
$string = str_replace("\r", '', $string);
The operation can be done in a single line:// Remove new line and carriage return
$string = str_replace(array("\r", "\n"), '', $string);
See also:// Remove new line and carriage return
$string = str_replace("\r", "\n", '', $string); // remove new lines
- Comment remplacer les retours chariot par des espaces dans une chaîne de caractères en PHP ?
- Comment remplacer les tabulations par des espaces dans une chaîne de caractères en PHP ?
| # | ID | Query | URL | Count |
|---|---|---|---|---|
| 0 | 11876 | en | https://en.ans.wiki/6815/how-to-remove-carriage-returns-from-a-string-in-php | 9 |