0

How php work with docx file. hi, I wont to open docx file replace some variable.

in *.docx file have Name : {variable1} Address : {variable2}

use php 5.1 version

Hayk Harutyunyan
  • 117
  • 1
  • 3
  • 17
  • Probably duplicate of http://stackoverflow.com/questions/1501623/reading-docx-office-open-xml-in-php – Eli Y Dec 02 '13 at 07:35

3 Answers3

0

You can checkout some PHP libraries below:
PHPDocX: http://www.phpdocx.com/
OpenTBS: http://www.tinybutstrong.com/opentbs.php

Skrol29
  • 5,402
  • 1
  • 20
  • 25
XuDing
  • 1,982
  • 18
  • 27
  • Thank you for response. second link not for free. firs link i try but have problem. (can not understand) in demo_ms_word.php file $yourname = "(no name)"; replace text. but how orginaize Name : {variable1} Address : {variable2} – Hayk Harutyunyan Dec 02 '13 at 07:51
0

.docx files are just zip files containing other files. You can try to unzip one using your favourite uzipping tool and explore it to locate the things you need to replace. Then you can proceed with PHP: http://www.php.net/manual/en/class.ziparchive.php

Carlos
  • 4,949
  • 2
  • 20
  • 37
0

you can use this simple library to do so: Github

Code example:

Text to text replace This code will replace $search to $replace in $pathToDocx file

$docx = new IRebega\DocxReplacer($pathToDocx);

$docx->replaceText($search, $replace);