Re: replace function in a file.

From: Date: Thu, 19 Apr 2001 16:17:27 +0000
Subject: Re: replace function in a file.
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-49383@lists.php.net to get a copy of this message
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)); fclose($fp); Regards, Avetis Mark Lo wrote: > Hi, > > 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. > > re: I know fopen is to open, read, and write to specific file, but not > finding and replacing.. > > Thank you > > Mark > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#49383) next »