I have a text file (in.txt) which has text on multiple lines. I need to search for a variable string and if found, delete that entire line, but keep the others. I have used the script below but it seems to get rid of all the data and write what I was searching for. Please can someone point me in the right direction? 'key' is the string for which I am searching.
$key = $_REQUEST['key'];
$fc=file("in.txt");
$f=fopen("in.txt","w");
foreach($fc as $line)
{
if (!strstr($line,$key))
fputs($f,$line);
}
fclose($f);