Jump to content

Recommended Posts

I'm assuming you meant to post a < br /> tag above.

 

I would suggest NOT converting line breaks to BR tags before saving to the database. Otherwise youwill have to convert again if you need to repopulate a textarea for editing.

 

Instead, when you get the content from the database, use nl2br() when displaying it.

User enters this into a textarea:

Here is
some text
with several
line breaks

 

You would enter that (as is) into the database.

 

Now when you need to display that text in HTML you would use this:

nl2br($textFromDB) which would output this:

Here is<br />some text<br />with several<br />line breaks

 

However if you need to populate the original text back into a textarea for editing you just use the value from the database w/o nl2br().

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.