I have a form to enter a description. A textarea is used for this purpose. I want to maintain any of the carriage returns that the user enters (i don't want it all to end up on one line). So I used the following before saving the value:
$description = htmlentities($description , ENT_QUOTES);
$description = nl2br($description );
This works great when I want to view the description just echoed to an html page. The problem I have is that I have an edit description page which will populate the textarea with the stored value, and then allow the user to make changes and save.
Now, say I originally enter the following in the original form to create the description:
This is line one.
This is line two.
This is line 3.
It will display like this if I just echo it out to HTML:
This is line one.
This is line two.
This is line 3.
However, if I populate my textarea in my edit form, it displays as follows:
This is line one.<br />
This is line two.<br />
This is line 3.
Besides being rather ugly, if the user saves the form, now even the html output will look like:
This is line one.<br />
This is line two.<br />
This is line 3.
Does anyone have a suggestion on how to deal with the newly entered to edit to display in html problem?
thanks,
kark