I'm stuck. Please help.
I have a .html file that I would like to open, replace certain texts or tags, and write it back to the file.
Just for testing. I have the following information in
test_file.html
test1
test2
test3
I would like to replace "test2" with "PHP". Below is my code, and it doesn't seem to work.
Any help is much appreciated.
<?
$fd = fopen("test_file.html", "r");
while (!feof($fd))
{
$buffer .= fgets($fd, 4096);
echo $buffer;
}
fclose($fd);
str_replace("test2","PHP",$buffer);
$fd = fopen("/web123/demo/test_file.html", "wb");
$done = fputs($fd,$buffer);
fclose($fd);
?>