Lets say I have a modestly sized text file (~850kb, 10,000+ lines)
And I want to replace a particular line (or several) spread out amongst the file.
Current methods for doing this include re-writing the whole file. The current method I use is read through the entire file line by line, writing to a .tmp file, and once I am done, I rename() the tmp file to the original source file.
It works, but it is slow. And of course, as the file grows, so will execution times.
Is there another way (using PHP) to get the job done without having to rewrite the entire file every time a line or two need to be replaced or removed?
Thanks! I looked around and could not find an answer to this on stackoverflow.