\n not working in my fwrite()

Posted by brett on Stack Overflow See other posts from Stack Overflow or by brett
Published on 2010-03-28T04:40:15Z Indexed on 2010/03/28 4:43 UTC
Read the original article Hit count: 374

Filed under:
|
|
|

Not sure what could be the problem.

I'm dumping data from an array $theArray into theFile.txt, each array item on a separate line.

$file = fopen("theFile.txt", "w");
foreach ($theArray as $arrayItem){
    fwrite($file, $arrayItem . '\n');
}
fclose($file);

Problem is when I open theFile.txt, I see the \n being outputted literally. Also if I try to programmatically read the file line by line (just in case lines are there), it shows them as 1 line meaning \n are really not having their desired effect.

© Stack Overflow or respective owner

Related posts about php

Related posts about file