| Forum Home | ||||
| Press F1 | ||||
| Thread ID: 108221 | 2010-03-19 05:36:00 | PHP display of multiline mysql value | Mike (15) | Press F1 |
| Post ID | Timestamp | Content | User | ||
| 868493 | 2010-03-19 05:36:00 | OK, so how do I explain this one :) I have a multiline string in a mysql varchar that I want to display in a webpage (PHP), however whenever I display it it only displays as a single line... What do I need to do to display the string 'correctly' (with new lines at the right place)? Cheers, Mike. |
Mike (15) | ||
| 868494 | 2010-03-19 07:19:00 | Not sure what the line delimiter would be in a multiline field, but assuming it's a linefeed, what do you get by displaying the result of implode("<br>", explode("\n", $mysql_var)) |
MushHead (10626) | ||
| 868495 | 2010-03-19 07:25:00 | Haha thanks MushHead, I just came back to say that I've figured it, and you've posted pretty much the same thing :) I didn't use the implode in mine, just the explode("\n", $mysql_var) Cheers, Mike. |
Mike (15) | ||
| 868496 | 2010-03-19 09:10:00 | Not sure what the line delimiter would be in a multiline field, but assuming it's a linefeed, what do you get by displaying the result of implode("<br>", explode("\n", $mysql_var)) That's a very inefficient way or doing it - use nl2br($mysql_var);or str_replace("\n", "<br />", $mysql_var);Nl2br() is the better of those two options. |
Erayd (23) | ||
| 1 | |||||