$first = "blah blah blah\n ha ha ha"; $second = str_replace("\n","<br>",$first); /* Why does it produce: [color=blue]blah blah blah <br> ha ha ha[/color] in a plain text file, and not: [color=blue]blah blah blah<br> ha ha ha[/color] ? [COLOR=darkblue]Shouldn't it replace [b]\n[/b] with [b]<br>[/b] instead of adding a [b]<br>[/b] after [b]\n[/b]?[/COLOR] Or should I just use preg_replace instead... */
Thanks.
Ah, fork it all.
string = preg_replace("/\r\n|\n\r|\n|\r/", "<br/>", $string);
So \r\n works, not \n... Weird, I recall, Windows uses \r\n as line breaks, while Linux uses \n as line breaks. I have a Linux server, how come I need to use \r\n? Any clue?
Linux is capable of binaries as well.
Your file has been seperated into \r\n by whatever wrote it.
Was it generated on a Windows system?
No, it was generated on a RedHat Linux, from a textarea.
have u tried using nl2br ? :/
No, I haven't, it works now by using \r\n, I was just wondering why it'd do that on a Linux...