Now: Tutorial for Web and Software Design > PHP > QA > PHP Content
> PHPFAQ - How do I turn newlines / returns into html breaks (<br)? [Bookmark it]
PHPFAQ - How do I turn newlines / returns into html breaks (<br)?


Question :

How do I turn newlines / returns into html breaks (<br>)?

Answer :We sugest you use the function nl2br which has the purpose of turning \n's into <br> (a side note since version 4.0.5 it turns \n into xhtml's </br>, to be xhtml compatible, this does not break html code). To use the function look below:


$text = "This\npage\nis\ngood";
$new_text = nl2br($text);


To read more about the function click on the link below
http://www.php.net/nl2br



[Bookmark][Print] [Close][To Top]
  • Prev Article-PHP:

  • Next Article-PHP:
  • Related Materias
    PHPFAQ - How google is you
    PHPFAQ - Are there any web
    PHPFAQ - How can I accept 
    PHPFAQ - How can I finance
    PHPFAQ - Where can I get P
    PHPFAQ - Where can I host 
    PHPFAQ - Where can I find 
    PHPFAQ - I am trying to cr
    PHPFAQ - Is there a librar
    PHPFAQ - How can I manage 
    Topics
    Photoshop Tutorial
     

    Special Effect

      3D Effect
      Photoshop Articles
    Programming Tutorial
     

    C/C++ Tutorial

      Visual Basic
      C# Tutorial
    Database Tutorial
     

    MySQL Tutorial

      MS SQL Tutorial
      Oracle Tutorial
    Graphic Design Tutorial
     

    Coreldraw Tutorial

      Illustrator Tutorial
      3D Graphics Articles
    Webmaster Articles
     

    Domain Service

      Web Hosting
      Site Promotion
    Java Tutorial&Articles
     

    Java Servlets

      JavaEE Tutorial
     

    JavaBeans Tutorial

    XML Tutorial&Articles
     

    XML Style Tutorial

      AJAX Tutorial
      XML Mobile
    Flash Tutorial&Articles
     

    Flash Video

      Action Script
      Flash Articles
    OS Tutorial&Articles
     

    Linux Tutorial

      Symbian Tutorial
      MacOS Tutorial