Inserting a blank line when writing a file

Discussion in 'PHP' started by vivsriaus, Jan 23, 2006.

  1. #1
    Here is a piece of my code

    while ($data = fgetcsv ($fp, 1000)) {
    $num = count ($data);
    for ($c=0; $c < $num; $c++) {
    $mult[$row][$c] = $data[$c].",";
    //$mult[$row][$c] = $data[$c]
    fwrite($fp1, $mult[$row][$c]);
    }
    $row ++;
    }

    I need to insert a blank line after each iteration of 'c' loop. ie., when the 1st iteration of the c loop exits, I need to insert a blank line and continue doin the same.

    Any inputs?
     
    vivsriaus, Jan 23, 2006 IP
  2. TMan

    TMan Peon

    Messages:
    126
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Just write the character "\n" to the file. That's an ASCII newline, so should give a newline in your file.

    Something like:

    fwrite ($fp1, "\n");
    Code (markup):
    Maybe it's a good idea to include some whitespace in your code as well, just to increase readability.
     
    TMan, Jan 23, 2006 IP
  3. vivsriaus

    vivsriaus Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I realize tht i posted a stupid qstn! I was in such a hurry tht i lost my mind! :)
    Anyway, thnx for the reply!
     
    vivsriaus, Jan 25, 2006 IP
  4. TMan

    TMan Peon

    Messages:
    126
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #4
    np :)

    Questions never are stupid, answers however can be very stupid.
     
    TMan, Jan 25, 2006 IP