Jump to content


Photo

Problem with nl2br


  • Please log in to reply
3 replies to this topic

#1 ldsmike88

ldsmike88
  • Members
  • PipPipPip
  • Advanced Member
  • 168 posts
  • LocationFlorida

Posted 27 October 2006 - 04:36 AM

I have a text area that I use nl2br on after you fill it out. Now that is just fine for displaying purposes, but if you go back to edit the information in the text area it shows it formatted like it should be but it also includes all the <br />'s. If you don't take out all the line breaks all of then double. How do you take out all the line breaks before displaying it in the text area? Thanks!

Michael

#2 php_joe

php_joe
  • Members
  • PipPipPip
  • Advanced Member
  • 175 posts

Posted 27 October 2006 - 04:52 AM

$test = str_replace("< br>", "", $text); will strip them out. (remove the space in the html break)
[url=http://darkswordsguide.com][/url]

#3 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 27 October 2006 - 05:10 AM

You should store the raw data from the user, after validating and washing it. Only use nl2br() when displaying the data.

Ken

#4 ldsmike88

ldsmike88
  • Members
  • PipPipPip
  • Advanced Member
  • 168 posts
  • LocationFlorida

Posted 28 October 2006 - 06:45 PM

Thanks! It works great now!

Michael




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users