Remove specific line from text file

Hey,
I’m currently sitting on a problem with php. I want to remove a specific line from a txt file, is there a way to do this?
Example: I have a variable called $line, which is an integer, in this example 5 ($line = 5;) and I have a text file called “text.txt”. The text file contains 10 lines and I want to replace the 5th line (because $line is 5). The text file now should have 9 lines, with the old 5th being removed and the 6th “going” to line 5, 7th to 6 and so on.

Thanks in advance,
Till

And what have you tried, thought about, considered?

Sponsor our Newsletter | Privacy Policy | Terms of Service