Delete just part of a text file

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
like_duh44
Forum Commoner
Posts: 63
Joined: Sat Jul 26, 2003 6:57 pm

Delete just part of a text file

Post by like_duh44 »

I'm making a script for the non-mysql users. Before, I would user mysql's DELETE and UPDATE, but now I have a script to read a file. How would i get about deleting just one line of a text file, not knowing the line number, or how many bytes of data until that point, just what the string is thats is to be deleted?

Also, the update function for a text file? If there isnt one, could I just have it delete those few lines and insert new ones with the updated values?
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

You could use file() to read the file into an array.
After that being done, you can loop the different array-values, find the one you need to remove/update, and do it.

Hope I was clear enough.
Post Reply