View Full Version : changing word file

03-14-2007, 07:07 PM
I am trying this code to edit word file, it works fine if the both strings are same lenght but not if both are of different length.
any help

$tmp= file_get_contents("work.doc");
$tmp = str_replace ("sys" , "asd",$tmp);
$tmp= file_put_contents("work2.doc" , $tmp);

03-14-2007, 07:35 PM
Yeah good luck with that... a Word file is a far cry from a plain text file and you can't expect to be able to treat it like a plain text file.

03-14-2007, 09:02 PM
Yeah, word documents are filled with extra formatting information along with the text. You might have better luck trying to find a class (http://www.phpclasses.org/browse/package/3553.html) to help you modify the file.

03-15-2007, 10:01 AM
i think supports OLE Container format (that of doc files) can do something
but not sure of it.