So My idea is to find a certain line in a text file using a regex then replacing the line with a blank essentially deleting it. However, im struggling with over writing the line with the blank in the text file
elseif ($inquiry=='delete'){
$file= fopen("database.txt", "r+") or die("File was not found on server");
$search = "/^[" . $Title . "%" . $Author . "%" . $ISBN . "%" . $Publisher . "%" . $Year . "]/i";
//search function
// What to look for
// open and Read from file
$lines = file('database.txt');//array
foreach($lines as $line){
// Check if the line contains the string we're looking for, and print if it does
if(preg_match($search, $line)){
echo preg_replace($line," ",$search);
echo "
entry deleted-<br>";
}
else{
echo "
entry not found<br>";
}
}
fclose($file);
}