I have a file named $dir and a string named $line, I know that this string is a complete line of that file but I don\'t know its line number and I
$dir
$line
It can be solved without the use of awk:
function remove_line($file, $remove) { $lines = file($file, FILE_IGNORE_NEW_LINES); foreach($lines as $key => $line) { if($line === $remove) unset($lines[$key]); } $data = implode(PHP_EOL, $lines); file_put_contents($file, $data); }