Hi,
I am trying to open an RTF and then change values in the document. I've created an RTF file in MS Word adn included the text "((data1))", which hopefully PHP should replace with "test words from PHP".
Problem is, using the w+ mode when fopen-ing creates a blank 0kb file and in r+ mode, it copies the RTF source and pastes it to the end of the document which is not what I want.
Heres the PHP, any ideas?
$filename = "template.rtf";
$fd = fopen ($filename , "w+"
;
$fdContents = fread ($fd, filesize ($filename));
$badStr = "((data1))";
$goodStr = "test words from PHP";
$fdContents = preg_replace($badStr, $goodStr, $fdContents);
fwrite($fd, $fdContents);
fclose ($fd);
Thanks.
I am trying to open an RTF and then change values in the document. I've created an RTF file in MS Word adn included the text "((data1))", which hopefully PHP should replace with "test words from PHP".
Problem is, using the w+ mode when fopen-ing creates a blank 0kb file and in r+ mode, it copies the RTF source and pastes it to the end of the document which is not what I want.
Heres the PHP, any ideas?
$filename = "template.rtf";
$fd = fopen ($filename , "w+"
$fdContents = fread ($fd, filesize ($filename));
$badStr = "((data1))";
$goodStr = "test words from PHP";
$fdContents = preg_replace($badStr, $goodStr, $fdContents);
fwrite($fd, $fdContents);
fclose ($fd);
Thanks.