creating a line break when saving a file

Discussion in 'PHP' started by mahmood, Dec 25, 2005.

  1. #1
    I wonder how I can make a line break when saving a file. for example:
    
    $firstLine = "this is a one line text";
    
    $secondLine = "this line has a line break
    ";
    
    PHP:
    The second line will be save with a line break. I tried to create the same effect using \n but it didn't work.
     
    mahmood, Dec 25, 2005 IP
  2. kniveswood

    kniveswood Well-Known Member

    Messages:
    764
    Likes Received:
    29
    Best Answers:
    0
    Trophy Points:
    120
    #2
    Do you mean a line break when you print/echo to html? If so, <br> is what you'll wanna try.
     
    kniveswood, Dec 25, 2005 IP
  3. onlyican.com

    onlyican.com Peon

    Messages:
    206
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Or if you want a break in the code then it is \n" at the end and ." at the beginning, this is good for forms

    echo "this is text\n"
    ."this text appears next to the other line, but in the code, on a new line."
     
    onlyican.com, Dec 26, 2005 IP
  4. mahmood

    mahmood Guest

    Messages:
    1,228
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks for reply

    I meant a line break when saving a text file.

    .
     
    mahmood, Dec 26, 2005 IP
  5. noppid

    noppid gunnin' for the quota

    Messages:
    4,246
    Likes Received:
    232
    Best Answers:
    0
    Trophy Points:
    135
    #5
    \r\n may solve the issue.
     
    noppid, Dec 26, 2005 IP
  6. blissallstar

    blissallstar Peon

    Messages:
    176
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Try this -> chr(13).chr(10) <- and see if it works.

    ascii for line break and line feed.
     
    blissallstar, Dec 28, 2005 IP