PolarBear 0 Posted November 14, 2007 Report Share Posted November 14, 2007 I've looked through the tutorials and searched the forums and can't seem to find anything on how to do this.I'm trying to write some string data to a .txt file and I would like the value of each variable I'm writing to file to be written to a new line.I can open the file with $file=fopen("MyFile.txt","w");then I tried thisInteresting, My post is getting truncated. Can't explain my question. Any ideas why? Quote Link to post Share on other sites
PolarBear 0 Posted November 14, 2007 Author Report Share Posted November 14, 2007 Let's try it this way.fwrite($file,$MyFirstVariable); Quote Link to post Share on other sites
PolarBear 0 Posted November 14, 2007 Author Report Share Posted November 14, 2007 fwrite($file,$MySecondVariable); Quote Link to post Share on other sites
PolarBear 0 Posted November 14, 2007 Author Report Share Posted November 14, 2007 I just can't seem to get out more than one line at a time. Never Mind. Sorry. Please Delete this thread. Quote Link to post Share on other sites
Ingolme 1,035 Posted November 14, 2007 Report Share Posted November 14, 2007 You can use \n to add line breaks, for example:fwrite($file,$myVar1."\n".$myVar2."\n".$myVar3); Quote Link to post Share on other sites
justsomeguy 1,135 Posted November 14, 2007 Report Share Posted November 14, 2007 I've seen my posts get truncated too, I'm not sure why. This line will open the file in write mode:$file=fopen("MyFile.txt","w");Ingolme showed you how to add a line break to the text. If you want to append new text to the end of the file instead of overwriting everything, you can open it with the "a" mode instead of "w". Quote Link to post Share on other sites
Synook 47 Posted November 15, 2007 Report Share Posted November 15, 2007 Interesting, My post is getting truncated. Can't explain my question. Any ideas why?Are you using Safari? That browser truncates my posts too, although in Opera it is fine. Quote Link to post Share on other sites
SpOrTsDuDe.Reese 1 Posted November 15, 2007 Report Share Posted November 15, 2007 Some browsers support scripts more then others. Quote Link to post Share on other sites
PolarBear 0 Posted November 16, 2007 Author Report Share Posted November 16, 2007 Ah, Thanks. Both questions answered. Yes I am using Safari. And it was the "\n" that I was looking for. the "w" and "a" I was aware of. They are covered in the tutorial. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.