Whats the best way to go about deleteing a whole line?
say you have a file with:
(1) Some Line
(2) Some Line
(3) Some Line
(4) Some Line
and you want to delete just "(3) Some Line"
when you searched for "(3)"
Here is my code so far:
$list = "items.txt"; \ Text File
$oldword = "(3)"; \ Word To Find
$results = file($list); \ makes results a variable for the file
$newword = ""; \ Word to replace with
$fp = fopen("$list", 'r'); \ Opens the file and preforms the read command
if ($fp){
$data = fread($fp, filesize($list));
fclose($fp);
$newdata = str_replace($oldword, $newword, $data); \ Does the String Replacing
$fp = fopen($list, 'w');
if ($fp){
fwrite($fp, $newdata);
fclose($fp);
}
}
See what it does now is only replace (3) with "" this means the text file will now say:
(1) Some Line
(2) Some Line
Some Line
(4) Some Line
Is There a cure for this disease? If you have the vaccine please help me out.
DarkBoy