Search code examples
phpflat-file

how can i force a linebreak in a txt database?


I'm working with PHP, and I would like to create a line-break in my .txt database after every input. Is this even possible and how? Please help, I have tried /n and <br> but these won't work. Some code:

fwrite($handle,$artikelnummer);
fwrite($handle,$newData);

Between these two I want a linebreak


Solution

  • Something like this?

    fwrite($handle, $artikelnummer);
    fwrite($handle, "\n");
    fwrite($handle, $newData);
    

    As Shikhar Bhardwaj pointed out, you could use PHP_EOL, instead of "\n", if you want to be completely OS platform independent...

    UPDATE: If what you expect is one empty line between lines, you have to write 2 newlines...:

    fwrite($handle, $artikelnummer);
    fwrite($handle, PHP_EOL . PHP_EOL);
    fwrite($handle, $newData);