I have a text file with the following data:
1_fjd
2_skd
3_fks
I want to replace a part in my text file using php. For example I want to do this:
Find the line that starts with "2_" and replace it with "2_word", so everything after '2_' is being replaced by:'word'. How can I do this in php?
fseekandfwrite, you'll just end up creating a new one and getting rid of the old, in some way or another) is something that doesn't immediately sink in usually. (It took me some discomfort, too.)execfanssed -i "s/2=.*/2=word/" file.txt