Jump to content

line breaks


kaliok

Recommended Posts

Hi I am having some trouble with converting html code to real line breaks in a textarea, I have the following code that I gets html code from a database and then puts it into a textarea but the str_replace I am using converts the text but puts the actual characters \r\n in the textarea, and doesn't actually turn it into a linebreak. (the br below is reality in triangular brackets!)

 

$paragraph=$row['paragraph'];

$paragraph=str_replace('br','\r\n',$paragraph);

.....

<textarea name="ud_text" cols="50" rows="15" maxlength="300"><? echo $paragraph ?></textarea>

 

Perhaps someone can help me with this?

 

Thanks in advance.

Link to comment
https://forums.phpfreaks.com/topic/53308-line-breaks/
Share on other sites

Guess I was being a little thick. Couldn't get nl2br to work, was using it in the wrong place, needed to put in after getting it from the database! So I converted the carriage returns/line breaks to a my own bracketed chars, then converted them on the front end, but wasn't behaving in the text area, so it prompted the question. Got the point now! Thanks for your help.

Link to comment
https://forums.phpfreaks.com/topic/53308-line-breaks/#findComment-263581
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.