note 61511 deleted from function.fwrite by nlopess

From: Date: Mon, 06 Feb 2006 12:17:43 +0000
Subject: note 61511 deleted from function.fwrite by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-103071@lists.php.net to get a copy of this message
Note Submitter: cudmore_mb at hotmail dot com ---- Hit counters? Well here's one I wrote: <?php if(($f = fopen("HitFile.txt","r+"))) { $Accessed = (int)fgets($f); $Accessed++; echo $Accessed; fseek($f, 0); fputs($f, $Accessed); fclose($f); } ?> works fine for me, but one thing I've been wondering about that I can't figure out is how to easily write to the beginning of a file and have the rest of the contents "push" down. So far I just read the contents into a variable using file_get_contents, and then write my newcontents.oldcontents to the file.. Surely there's an easier way, that's what I'm investigating now..

« previous php.notes (#103071) next »