How to force PHP to read newlines and returns as <br>
The title is a little off im sorry. however what the scenario IS.
I'm reading from a MySQL Database the field format is "mediumtext".
At current it knows when there is a new line from hitting enter/return. there is no html involved.
however when i pull this from the database onto my page, there is no formatting. however if you look at the html the code it beautifuly formatted with new lines!
ive already got a find/replace function setup for some simple BBCode so might be able to use this.
so does anybody have ideas on how I can either us开发者_如何转开发e my find/replace to find "new lines?" or how to simply force the new lines some how, if you understand me?
You can use
nl2br— Inserts HTML line breaks before all newlines in a string
Example from Manual:
echo nl2br("Welcome\r\nThis is my HTML document", false);
will output
Welcome<br>
This is my HTML document
加载中,请稍侯......
精彩评论