Jump to content

Automatic <br>


pndof12006

Recommended Posts

pndof12006: Let me explain how it works:

\n (LF - line feed) - Linux uses this to display a new line
\r (CR - carriage return) - Macintosh use this to display a new line
\n\r (CRLF - carriage return, line feed) - Windows uses this to display a new line

[url=http://php.net]nl2br[/url] converts LF to [tt][nobbc]<br />[/nobbc][/tt]. If you want to convert all types of new lines to \n, then use this: [code]$string = preg_replace("/(\r\n|\r|\n)/","\n",$string);
$string = nl2br($string);[/code]

Or perhaps even better: [code]$string = preg_replace("/(\r\n|\r|\n)/","<br />\n",$string);[/code]
Link to comment
https://forums.phpfreaks.com/topic/24067-automatic/#findComment-109358
Share on other sites

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.