Jump to content

[SOLVED] Remove break lines


SirChick

Recommended Posts

//non-escaped version
str_replace('\n',''$str);
//escaped version
str_replace('\\n',''$str);

 

Those should do it. However, I forget if PHP reads \n as a new line inside a function or not, so try both ways, see which produces the output correctly.

That code wont work. You must use double quotes when using whitespace characters within strings:

 

$str = 'G
f
h
s
hhss
s
f';

$str = str_replace(array("\r\n", "\r", "\n"), ' ', $str);

echo $str; // outputs: G f h s hhss s f

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.