I have a MySQL table with 2 columns:
text: stores a multi-line text which could have line breaks as\n, \r, \r\n.... The text is inserted via a webform and could have been inserted by any browser on any OS.line_break: represents what type of line break this particular text will use (could be\n,<br>,<br />, ...). This is also inserted via a webform by a user.
In PHP I then do the replacement:
$text = preg_replace ("/(\r\n|\r|\n)/", $row['line_break'], $row['text']);
Interestingly, if the line break is stored in the DB as \n I will actually show \n instead of the newline. On the other hand, the following regexp will work correctly:
$text = preg_replace ("/(\r\n|\r|\n)/", "\n", $row['text']);
How do I need to store the newline in the DB for it to "work" correctly?
How do I need to store the newline in the DB for it to "work" correctly?.