[PHP] searching and replacing in a file

2003-12-15 Thread Richard Kurth
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. Below is a peace of what I need to search through. I need to find the string subscribe_policy = open and replace it with subscribe_policy = open+confirm. Then save the whole file.

[PHP] searching and replacing in a file

2003-12-15 Thread Richard Kurth
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. Below is a peace of what I need to search through. I need to find the string subscribe_policy = open and replace it with subscribe_policy = open+confirm. Then save the whole file.

Re: [PHP] searching and replacing in a file

2003-12-15 Thread olinux
$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);

Re: [PHP] searching and replacing in a file

2003-12-15 Thread John Nichel
Richard Kurth 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. Below is a peace of what I need to search through. I need to find the string subscribe_policy = open and replace it with subscribe_policy = open+confirm. Then