Reputation: 3021
How can i maintain the description of a product as i can see it in the mysql database which includes the carriage returns e.t.c but no HTML.
Is there a function in PHP which can interpret the bits required so when it renders it has
or
?
Upvotes: 0
Views: 2854
Reputation: 53319
If I understand you correctly, you probably want to use this function:
$text_to_display = nl2br($text_from_database);
This will add a br tag before all newlines, so it will show up as line breaks in the html output.
Upvotes: 1
Reputation: 26380
nl2br(), described here: http://php.net/manual/en/function.nl2br.php
This function converts the newline character into <br />
tags. This preserves newlines visually in HTML.
Upvotes: 1