trouble with fwrite

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
psychotomus
Forum Contributor
Posts: 487
Joined: Fri Jul 11, 2003 1:59 am

trouble with fwrite

Post by psychotomus »

Code: Select all

$fp = fopen("emails.txt", "a");
		fwrite($fp,$email);
		fclose($fp);
this is the code i got, it writes to the end of the file, but i cant get it to go to the next line.

ive tried fwrite($fp,"\n".$email); but that just wrote some weird ascii, how can i get it to go the next line and write?
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

...

Post by kettle_drum »

It should work if you use \n. I know that it works when used with fputs.

fputs($fp, $email."\n");
psychotomus
Forum Contributor
Posts: 487
Joined: Fri Jul 11, 2003 1:59 am

Post by psychotomus »

i guess it does work, but when i open the text file where it stores the $emails in, it has a little square box and all the entrys are on a single line, i guess it doesnt automaticly line feed it, but uses the squares as seperators for new lines
Tubbietoeter
Forum Contributor
Posts: 149
Joined: Fri Mar 14, 2003 2:41 am
Location: Germany

Post by Tubbietoeter »

try this:

fputs($fp, $email."\r\n");
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

...

Post by kettle_drum »

Well it maybe because what ever OS your reading from has a different line break code and so \n doesnt break to a new line.
Post Reply