SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    will code HTML for food Michel V's Avatar
    Join Date
    Sep 2000
    Location
    Corsica
    Posts
    552
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    xhtml compliant output

    I've found the function nl2br() very handy when manipulating text-files, but how do I make it output <br /> tags to comply with xhtml rules ?
    (I've tried to code a quick eereg_replace but that didn't work)
    [blogger: zengun] [blogware contributor: wordpress]

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Shin Ma, you might want to have a look at str_replace() see the following code:

    PHP Code:
    $str "Hello Mom\n I am happy little string\n\n who needs some manpulation like some \n &lt;br&gt;
     tags and the such"
    ;
    $str str_replace("<br>""<br />"nl2br($str));
    print 
    $str
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  3. #3
    Node mutilating coot timnz's Avatar
    Join Date
    Feb 2001
    Location
    New Zealand
    Posts
    516
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Also note that as from PHP 4.0.5 nl2br() is XHTML compliant. All versions of PHP below this still just convert to <br>


Bookmarks

Posting Permissions

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