Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: nl2br

  1. #1
    New Coder
    Join Date
    Mar 2006
    Posts
    66
    Thanks
    3
    Thanked 0 Times in 0 Posts

    nl2br

    Hi,

    I am using the nl2br() function to add line breaks (rn) to text before storing in a database. Problem is that on my edit page I'm getting these characters echoed. Is there a way of stripping these out - ie. reversing nl2br?

    Thanks

    Chris
    Chris Holbrook
    Freelance Designer and Musician
    Freelance Web Designer and Musician: Bristol, UK
    Visit my site: http://www.chrisholbrook.com

  • #2
    Senior Coder kbluhm's Avatar
    Join Date
    Apr 2007
    Location
    Philadelphia, PA, USA
    Posts
    1,509
    Thanks
    3
    Thanked 258 Times in 254 Posts
    Why are you storing them?

    Don't store them... call the text from the database and add the breaks when you display it. There will be less data to store and you'll be able to do more with the text in the long run.
    Last edited by kbluhm; 08-27-2007 at 06:09 AM.

  • #3
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,106
    Thanks
    11
    Thanked 101 Times in 99 Posts
    PHP Code:
    <?
    $str
    =str_replace("<br />","\n",$str);
    ?>
    but kbluhm is quite right.
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •