Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
02-03-2003, 01:17 PM #1
- Join Date
- Jun 2002
- Thanked 0 Times in 0 Posts
Read records from file and delete them?
Is there a way that I can read the first number of records of a file, say 200, and then delete those 200 records? It is a large file, so I would prefer to minimize the amount of file rewriting I do.
02-04-2003, 04:23 PM #2
- Join Date
- May 2002
- Perth Australia
- Thanked 98 Times in 96 Posts
Hi, you can open a file for reading and writing with
and traverse the file with fseek() etc, but the best you will be able to do (AFAIK) is overwrite the first $x lines with '' , you will still have say, 200 empty lines at the start of your file.
unless your file is repressivly large ... and if it is it should not be - then reading the file and rewriting really is the best solution, & as long as you are not echoing the data to screen or anything should be fast enough.
on *NIX there are the direct i/o functions, dio_truncate() will truncate the file to $x bytes, though from what 'end' I can't say as I have yet to use them.
MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)