PDA

View Full Version : str_replace


Saj
05-20-2003, 05:30 PM
Can someone help me use this to pretty much open a file, parse the data and put it into a variable, change one tag of the variable, and then rewrite the file with the same information as the variable.

Here is what I have:


$postsname = "includes/posts.txt";
$postsfile = fopen($postsname, "r");
$postdata = fread($postsfile, filesize($postsname));
$new_postdata = str_replace("<!-- End of Post -->", "Replace Text<!--End of Post -->", $postdata);
fclose($postsfile);
$postsfile_write = fopen($postsname, "w");
fwrite($postsfile_write, $new_postdata);
fclose($postsfile_write);


Thanks for your help.

Saj
05-20-2003, 07:55 PM
Never mind, I got it sorted out

Spookster
05-20-2003, 07:57 PM
No problem. Glad we could help. Make sure and post the solution we helped you to find so that others can benefit. :)

Saj
05-21-2003, 12:19 AM
There is no solution...well that's the solution. I made a change on the actual post and didn't realize it would work :D