After deleting an entry from a file, am left with a blank line where the entry used to be, and would like to know how to get rid of it at the same time of script execution.
My data.txt file has the following entries:
1
12
123 (line to be deleted)
1234
(blank line, carriage return)
plus an empty line at the bottom of the line which I would like to keep but not the one left after an entry has been deleted.
what I’m left after entry has been deleted:
1
12
1234
(blank line, which I want to keep intact)
Here is my present working code below:
$bodycont = preg_replace("/\b({$_POST['inscripnum1']})\b/","",$index);
How can I implement something on the same line to delete the line that the number was on?
Any help would be greatly appreciated.
Thank you
Capture the line break in the regex: