$filename = '/path/to/file.txt'; $contents = file_get_contents($filename); $contents = str_replace($search,$replace,$contents);
$handle = fopen($filename, "w"); if (fwrite($handle, $contents)) { echo 'file write successful'; } else { echo 'file write failed'; exit; } fclose($handle); also - there's no need to enclose the variable $file in quotes here: > $fp = fopen("$file", "w+"); olinux --- Richard Kurth <[EMAIL PROTECTED]> wrote: > How can I read through a file and find a string and > then replace it with a > new string and then save the whole file. > __________________________________ Do you Yahoo!? New Yahoo! Photos - easier uploading and sharing. http://photos.yahoo.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php