Replies: 3   Views: 3385
Replace multiple occurrences of variable not working
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by pingtech  · 25-09-2012 - 20:35

I have a doc that I am using addTemplateVariable to substitute for the variables in a word doc. It works fine on the first occurrence, but not on any subsequent. Is there a better method, or any suggestions on how to accomplish this?

Or do I have to modify the addTemplateVariable to do this?

Example doc: (substituting for $filenumber")

File # $filenumber$
lots of stuff
File $filenumber$

Posted by admin  · 11-04-2013 - 12:13


We've checked your issue and everything is working fine; a placeholder is replaced all times in DOCX file. Please send us your DOCX file and php script to test both of them.


Posted by pingtech  · 11-04-2013 - 12:13

I will verify that it works, but I went back and it appears my word doc had an issue with 2nd->N occurrences of the variable.

Thank you for your prompt response.