Jump to content

[SOLVED] nl2br or str_replace cannot replace new lines with <br />


obay

Recommended Posts

I'm trying to replace new lines "\n" with "<br />"s but none of these seem to work:

 

nl2br($text)

str_replace("\n",'<br />',$text)

 

oh, it adds the <br /> all right, but it still doesn't remove the \n.

 

If text is

 

the quick
brown fox

 

it is converted to

 

the quick
<br />brown fox

 

when it's supposed to be

 

the quick<br />brown fox

 

I've tried everything else: ereg_replace, using "%0D%0A" instead of "\n", using "\n\r" instead of "\n".. etc.

 

Any suggestions?

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.