-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A function returning all variables in docx template #2385
Labels
Comments
For all variables -> PHPWord/src/PhpWord/TemplateProcessor.php Lines 704 to 712 in 7743802
If you want without blocks: public function getVariablesWithoutBlock(): array
{
$variables = $templateProcessor->getVariables();
$keysToRemove = [];
$key_endBlock = null;
foreach ($variables as $index => $variable) {
if ($key_endBlock && $index <= $key_endBlock) {
$keysToRemove[$index] = $index;
continue;
}
$key_endBlock = array_search("/$variable", $variables, true)
if ($key_endBlock) {
// Is a block
$keysToRemove[$index] = $index;
}
}
return array_values(array_diff_key($variables, $keysToRemove));
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is your feature request related to a problem? Please describe.
I want to make dynamic form input base on all the variables exist in docx template.
Describe the solution you'd like
I think it's better if there is a function that can return all variables inside the docx
Additional context
If it feature already exist feel free to tell me
The text was updated successfully, but these errors were encountered: