Page 1 of 1
How might I write a variable to a file?
Posted: Sat Aug 17, 2002 12:16 pm
by gotDNS
Say I stick an array of things into a variable....(for DLing a Diary).....how would i write that variable in, oh say, "diary.txt"....
furthermore, how would i have it automatically delete the file after they are done using it?
THANKS!
Posted: Sat Aug 17, 2002 12:30 pm
by lc
Dling a diary? can you explain?
of course you can stick the contents of an array in a textfile and retrieve them later.
For instance I ususally create:
$include = "the array's contents";
then write that in.
but errrr can you explain in more detail? do you want to create a diary script? Or news thing? That's not too hard. I have one at the alienhelpdesk. (called the articler) is that what you need?
Posted: Sat Aug 17, 2002 10:29 pm
by volka
why do you want to write the data to a file and then let the user download it? Why not simply write the contents as plain text? The user may save the file from within the browser.
If you want to emphazise "hey, a file is comming - save it" you may use header informations like
header("Content-Disposition: attachment; filename=diary.txt");
You may also (or as addition) use the
gzip functions since (I think) all browsers offer "save file" for application/x-gzip
Posted: Sat Aug 17, 2002 10:58 pm
by gotDNS
hey guys...sorry to trouble u all...i got it.....me and my friend figured it out! Thanks for your help, though!
later on, -Brian