modifyMergeFields

modifyMergeFields

ADVANCED / PREMIUM TRIAL

Modifies the values associated with Word template merge fields.

Description
public modifyMergeFields (array $data, [array $options])

This method allows to modify the value of a series of Word merge fields.

With setTemplateSymbol, merge field symbols (« ») can be used to do replacements.

Parameters

data

An array with the names of the merge fields as keys and their corresponding values.

options

The possible keys and values of this array are:

Key Type Description
target string Possible values are: document (default), header, footer. This option sets the scope of the replacement procedure.
Exceptions

Method not available.

Code samples

Example #1

The resulting Word document looks like:

Release notes
  • phpdocx 15.0:
    • handle not default merge field contents.
    • not case sensitive when doing replacements.
  • phpdocx 12.5:
    • new method.