Posted: Fri Nov 26, 2004 5:24 pm
oups..thats my code..sorry..

A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
class PerlCounter {
var $header = "#COUNTER-1.0\n";
function increment($filename) {
$offset = strlen($this->header);
$counter = 0;
$fp = fopen($filename, 'r+');
if ($fp) {
$contents = fread($fp, filesize($filename));
if ($contents) {
$counter = intval(trim(substr($contents, $offset)));
}
++$counter;
$contents = "{$this->header}$counter\n";
rewind($fp);
fwrite($fp, $contents);
ftruncate($fp, strlen($contents));
fclose($fp);
}
return $counter;
}
} // end class