Jump to content

Line breaks written to file do not show up.


dlite922

Recommended Posts

have loaded apache and php 5 on xp pro.

 

don't know why this is happening but when i write to a file, the new line (line break) '\n' character does not show up as a line break but as a square (which is the "unknown symbol" symbol)

 

here's the little tiny code from tigzag tutorials basically copy and pasted. my original application is to find all mp3's in a directory. and let the user build a .m3u playlist and handed over to an embedded windows media player.

 

$myFile = "testFile.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = "Bobby Bopper\n";
fwrite($fh, $stringData);
$stringData = "Tracy Tanner\n";
fwrite($fh, $stringData);
fclose($fh);

 

file shows up with:

 

Bobby Bopper[]Tracy Tanner[]

 

 

instead of:

 

Bobby Bopper

Tracy Tanner

 

google searches return nothing related. can't imagine anybody having this problem. Going nuts, i've done this before dont' know what i'm doing different.

 

 

I guess you are using notepad to view the file. Notepad only understands \r\n. When use \r or \n for new lines and display it in notepad all you'll get is square characters in placement of those chars. Change \n to \r\n and you'll see the new lines.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.