Re: Overwriting specific lines in text files without rewriting the whole thing.

From: Date: Mon, 26 Jun 2000 20:53:27 +0000
Subject: Re: Overwriting specific lines in text files without rewriting the whole thing.
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-3201@lists.php.net to get a copy of this message
Unfortunately, I have something like 1100 pages, if you count all of the dynamically generated pages... I'm sure it's possible, and I think I could do it in C or something, but I've looked over the PHP filesystem functions a bunch and can't see it... /s/ John ----- Original Message ----- From: Carroll Barrett <cbarrett@inalt.com> To: <php-general@lists.php.net> Sent: Monday, June 26, 2000 5:02 PM Subject: Re: [PHP-GENERAL] Overwriting specific lines in text files without rewriting the whole thing. > John, > > You might consider having a separate counter file for each page, > if you don't have too many pages. > > Regards, > Carroll Barrett > > -----Original Message----- > From: John Biesnecker <amraam@ao.net> > To: php-general@lists.php.net <php-general@lists.php.net> > Date: Monday, June 26, 2000 3:48 PM > Subject: [PHP-GENERAL] Overwriting specific lines in text files > without rewriting the whole thing. > > > I have created rather simple file-based page hit counter for my > site (because I can't use SQL or anything else). Currently I am > reading the entire thing into an array using file(), finding the > correct line, editing it and writing the entire thing back into a > file. > > After a few weeks of content development, however, my counter > data file has gotten very large, and reading and writing the > entire file is beginning to take a noticable amount of time. I'm > already sorting the file so the most accessed pages are on top, > hoping to reduce time needed to find the correct entry. > > I'm wondering if there is a way that while reading the file line > by line and I can alter a single line and write it back to the > file without disturbing the rest of the lines and then exit. > Also, if there is, will I see any performance improvement worth > the code rewrite. > > Thanks. > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#3201) next »