I have a text file names data.dat containing space separated strings on each line. I want to delete a whole line starting with a specific from it, Please provide tested php code for it. I'm using php 5.4+
File Contents :
abc samle sample
this abc sample
xyz test sample sample
For example, I have $str="this"
. So in this case I want to delete 2nd line, For general that could occur at first line or middle or end. Main thing is I dont want any empty line. So new file should be
abc samle sample
xyz test sample sample