Results 1 to 6 of 6
  1. #1

    replace enter with <br>?

    in forums (like this one) you dont have to type <br> for a line break, how do you do this i need it for my form.

  2. #2
    Join Date
    Mar 2004
    Posts
    1,301
    I think we can use this to print out the output...

    it will replace a new line with <br>

    str_replace("\n","<br>",$str); // where $str is the string output

  3. #3
    Join Date
    Oct 2003
    Location
    Chicago, Illinois
    Posts
    110
    PHP has a function specifically for this.

    nl2br()

    http://php.he.net/manual/en/function.nl2br.php
    John Kata

  4. #4
    Join Date
    Mar 2004
    Posts
    1,301
    oh that's sweet huh : ) the nl2br() function, i didn't know it before

    Thanks inFused

  5. #5
    k, thanks for all your help

  6. #6
    Join Date
    May 2002
    Location
    UK
    Posts
    2,994
    nl2br() is also XHTML compliant i.e. new lines are replaced with <br />

Posting Permissions

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