<?php function incrementCounter($counterFile) { //INCREMENT THE COUNTER
$current=readCounter($counterFile);
$current++;
if(!$handle = fopen($counterFile, "w")) { return false; }
else { if(fwrite($handle, $current) === FALSE) { return false; } }
fclose($handle);
return true; }
function readCounter($counterFile) { //OUTPUT THE CURRENT COUNT
$contents=file_get_contents($counterFile);
if(is_numeric((int)$contents)) { return ((int)$contents); }
else { return 0; } }
$counterFile="video1.txt";
incrementCounter($counterFile); //INCREMENT THE COUNTER
echo readCounter($counterFile); //OUTPUT THE CURRENT COUNT
?>
almostbob
Posting Sensei
3,149 posts since Jan 2009
Reputation Points: 571
Solved Threads: 376