PDA

View Full Version : [php] overwriteing with fwrite()



Johnny64
August 14th, 2003, 05:54 PM
Hoi



$handle = fopen($filename, 'a');
fwrite($handle, $somecontent));
fclose($handle);

this will add $somecontent to a text(i think)
but how do i overwrite whats all ready in the text with $somecontent ??

:} thanx :}

Jubba
August 14th, 2003, 07:30 PM
$file = "myText.txt";

$fp = fopen($file, "a");

ftruncate($fp, 0);

$fwrite($fp, $somecontent);

$fclose($fp);


ftruncate is what you want. Check the manual for details.

Johnny64
August 15th, 2003, 04:20 AM
thanks :}