Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.