removeTemplateVariable

removeTemplateVariable

TRIAL / ADVANCED / PREMIUM

Removes a phpdocx placeholder variable from the Word document.

Description
public removeTemplateVariable (string $variableName[, string $type[, string $target, [array $options = array()]]])

This method allows to remove an "unused" placeholder variable.

There are two options: just remove the placeholder variable ($type = 'inline') or remove the whole paragraph that contains it ($type = 'block').

Parameters

variableName

The name of the variable you want to remove.

type

It may be 'inline' if one wants just to remove the variable or 'block' (default value) if one wants also to remove the containing paragraph.

target

Possible values are: document (default value), header, footer, footnote, endnote or comment.

options

The possible keys and values of this array are:

Key Type Description
firstMatch bool If the variable appears more than once within the Word document and firstMatch is set to true, phpdocx will only remove the first occurrence of the variable within the Word document.
Code samples

Example #1

Release notes
  • phpdocx 18.0:
    • firstMatch option.