Hello,
What license and version of phpdocx are you using?
We recommend you read the following documentation pages:
- getTemplateVariables : https://www.phpdocx.com/api-documentation/templates/get-Word-template-variables
- Good practices when working with templates (Adding placeholders to templates section): https://www.phpdocx.com/documentation/cookbook/good-practices-with-templates
Your DOCX contains the symbol used to wrap placeholders ($) a regular content (such as $$PFEE_AMT$ ). Therefore, methods that detect the variables automatically (such as getTemplateVariables) can't get them correctly.
We recommend you doing one of the following approaches:
- Remove $ as regular content in the template. For example, write $PFEE_AMT$ instead of $$PFEE_AMT$ . When you replace the variable you can add the extra $ in the new text.
- Use another symbol to wrap placeholders that is not used as regular content, for example # in your template.
- Enable the parseMode option if you can't change the placeholders used in the template:
$docx = new CreateDocxFromTemplate('sample.docx', array('parseMode' => true));
CreateDocxFromTemplate::$regExprVariableParse = '(.+)';
print_r($docx->getTemplateVariables());
- Use ${} to wrap placeholders. For example $${PFEE_AMT} (in this case you can keep $ as regular content).
We recommend you use ${} to wrap placeholders, that is the more accurate and easiest approach for your template. After updating your template using ${} you can get all template variables as needed:
$docx = new CreateDocxFromTemplate('sample.docx');
$docx->setTemplateSymbol('${', '}');
print_r($docx->getTemplateVariables());
Regards.