Re: Help with files

From: Date: Mon, 02 Feb 2004 03:38:51 +0000
Subject: Re: Help with files
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-176554@lists.php.net to get a copy of this message
Mr. Austin wrote:
Hello all, I am trying to open a file (successful), then rewrite over the file when it is saved via a form on a website. I have used the following code, yet it simple rewrites from the file pointer, but does not clear the file before writing. Thanks for any help. <?php $buff = fopen("sample.txt", "r+"); $text = "This is new text for yay"; if(!fwrite($buff, $text)) { print("Unable to write to file"); } else { print("File written successfully"); } ?>
Use the manual, Luke. http://us4.php.net/manual/en/function.fopen.php The word you're looking for here is 'truncate'. -- By-Tor.com It's all about the Rush http://www.by-tor.com

« previous php.general (#176554) next »