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 4 of 4
  1. #1
    Regular Coder
    Join Date
    Apr 2007
    Posts
    317
    Thanks
    24
    Thanked 3 Times in 3 Posts

    Text area new paragraph

    I'm curious if i have a text area that i will be writing in, is it possible to detect a seperation in paragraphs or new lines?

    For instance
    Code:
    This is my first paragraph This is my first paragraph This is my first paragraph This is my first paragraph This is my first paragraph
    
    This is my second paragraph This is my second paragraph This is my second paragraph This is my second paragraph
    Now what i want to do is just insert a <br> tag whenever there is a new line.

    I don't really want to use a RTE. But if this cannot be done then i will do so.

    Thanks in advance.

  • #2
    Regular Coder
    Join Date
    Mar 2009
    Posts
    120
    Thanks
    13
    Thanked 3 Times in 3 Posts
    PHP Code:
    $textarea str_replace(PHP_EOL,'<br>',$textarea); 
    That should get the job done...

  • #3
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    PHP has a built in function for this called nl2br. It inserts a <br /> (or <br> if its running old school) I believe its after the \n.
    Code:
    Insert text
    
    on a new line.
    filtered through nl2br would become:
    Code:
    Insert text<br />
    <br />
    on a new line.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #4
    New to the CF scene
    Join Date
    Jun 2009
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Interesting... didn't know about nl2br... you never stop learning from others
    Last edited by Inigoesdr; 06-20-2009 at 06:14 PM.


  •  

    Posting Permissions

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