Can I perform operatrions on MS word file using php? If I can than is there a special way to do so?
For example there is file abc.doc
It contains a line " Hello [[field1]],"
Now i want to find and replace this [[field1]] by "Mike"
How can i do this?
Output will be:
Hello Mike,
Thank you
operations on MS word file
Moderator: General Moderators
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
- itsmani1
- Forum Regular
- Posts: 791
- Joined: Mon Sep 29, 2003 2:26 am
- Location: Islamabad Pakistan
- Contact:
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
any help
Code: Select all
<?PHP
$tmp= file_get_contents("work.doc");
$tmp = str_replace ("sys" , "asd",$tmp);
$tmp= file_put_contents("work2.doc" , $tmp);
?>- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Word files are binary, you cannot simply str_replace() things in them.