Date: 07/04/01
- Next message: Arcady Genkin: "Re: [PHP] error_log not obeyed"
- Previous message: ..s.c.o.t.t..: "RE: [PHP] How to prevent people from downloading images"
- In reply to: David Robley: "Re: [PHP] Deleting a string from a text file"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
you could also do it this way:
$ofile = "file.txt"; // original file
$nfile = "new.file.txt"; // new file
$string = "original"; // what needs to be replaced
$replace = "replacement"; // what to replace it with
$data = file($ofile); // original file's data
$fp = fopen($nfile,"w") or die("Cannot open for writing");
while ( list(,$line) = each($data) ) {
$line = preg_replace("/$string/", $replace, $line);
fwrite($fp, $line) or die("Cannot write");
}
fclose($fp);
$r = copy($nfile,$ofile) or die("Unable to copy");
$r = unlink($nfile) or die("Cannot unlink");
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe <email protected> For additional commands, e-mail: php-general-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: Arcady Genkin: "Re: [PHP] error_log not obeyed"
- Previous message: ..s.c.o.t.t..: "RE: [PHP] How to prevent people from downloading images"
- In reply to: David Robley: "Re: [PHP] Deleting a string from a text file"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

