Re: [PHP] replace function in a file.

2001-04-19 Thread Steve Werby
"Mark Lo" <[EMAIL PROTECTED]> wrote: > Is there any function exists which to open a specific file, then find a > specific word, if found, then replace that word with something else. In addition to the solution mentioned using PHP filesystem functions, you could use Unix command like grep, sed

Re: [PHP] replace function in a file.

2001-04-19 Thread Avetis Avagyan
Hello, something like this: $filename="your_file_name.txt"; $fp = fopen($filename, "r+") or die ("Could not open file"); $content = fread ($fp, filesize($filename)); $new_content = str_replace("old_word", "new_word", $content); rewind($fp); fwrite($fp, $new_content); ftruncate($fp, ftell($fp)); f