if you want that the number starts from zero every time, use fopen with w+ . if you want that it starts from zero after a certain amount of time, tell php to delete/backup the file after a certain amount of time (240 hours in the example below), so that the file will be recreated:
$timenow=time();
$timeout='240';
$fp=fopen("textfile.txt", "a+");
fputs ($fp,"your number here".",".time()."\n");
fclose($fp);
$zz = fopen("textfile.txt","r");
$zeile = explode(",",fgets($zz,100));
echo "time in file: $zeile[1]<BR>";
fclose($zz);
function renam()
{
global $timenow;
$file = "$timenow.txt";
if (!rename($file, $backupfilename)) {
echo "<BR>file $file not found, or permission denied, or file already exists</BR>";
} else {
echo "<BR>file $file renamed successfully to $backupfilename</BR>";
}
}
$et=$zeile[1]+3600*$timeout;
if ($timenow > ($zeile[1]+3600*$timeout)) {
{
echo "<BR>time at this moment ist bigger than time of the backup, time to backup the file!</BR>";
renam();
}
I think the example above should work