Question #6816   Submitted by Answiki on 09/30/2022 at 08:29:32 PM UTC

How to replace carriage returns by spaces in a string in PHP?

Answer   Submitted by Answiki on 09/30/2022 at 08:34:07 PM UTC

In PHP, to replace line breaks and carriage returns by spaces in a string, one can use the str_replace function:

// Replace new line and carriage returns by spaces
$string = str_replace(array("\n", "\r"), ' ', $string);

See also:



4 events in history
Question by Answiki 09/30/2022 at 08:34:57 PM
How to replace carriage returns by spaces in strings in PHP?
Answer by Answiki on 09/30/2022 at 08:34:07 PM

In PHP, to replace line breaks and carriage returns by spaces in a string, one can use the str_replace function:

// Replace new line and carriage returns by spaces
$string = str_replace(array("\n", "\r"), ' ', $string);

See also:



Answer by Answiki on 09/30/2022 at 08:31:02 PM

In PHP, to replace line breaks and carriage returns by spaces in a string, one can use the str_replace function:

// Replace new line and carriage returns by spaces
$string = str_replace(array("\n", "\r"), ' ', $string);

See also:



Question by Answiki 09/30/2022 at 08:29:32 PM
How to replace carriage returns by spaces in a string in PHP?
# ID Query URL Count

Icons proudly provided by Friconix.