View Full Version : erasing txt file before writing new info
12-20-2003, 11:00 PM
i have a script that writes the content from a textarea to a .txt file, but i want it to clear the txt file before posting new info into it......
$File = "top30message.txt";
$Open = fopen($File, "a");
$message = $_GET['message'];
12-21-2003, 12:08 AM
It will rewrite the file automatically.
12-21-2003, 01:31 AM
$Open = fopen($File, "w");
12-21-2003, 02:23 AM
Yeah use w mode. It will automatically rewrite the file with the contents of the textarea.
12-21-2003, 02:29 AM
how do i echo the info from a txt file?
12-21-2003, 03:50 AM
to do this you would need to read the text file. There are many ways to do this, and this is how i usually do it:
$fh = fopen("filename.txt", "r");
echo fgets($fh, 4096);
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.