Forum


Replies: 2   Views: 1034
Use replacevariablebytext with multiple targets
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 admin  · 06-06-2021 - 19:54

Hello,

Please check the documentation available on https://www.phpdocx.com/documentation/cookbook/replace-placeholders-targets. The target option allows setting a single value, but you can replace all targets adding just two lines:

foreach (array('document', 'header', 'footer', 'footnote', 'endnote', 'comment') as $target) {
  $docx->replaceVariableByText($variables, array('target' => $target));
}

Regards.