replaceWordFragment

replaceWordFragment

PREMIUM TRIAL / ADVANCED

Bulk processing. Replaces placeholder variables by WordFragment.

Description
public replaceWordFragment (array $variables, array $options)
Parameters

variables

This is an array that each position sets a DOCX document. In this array, another array set the new contents.

options

The possible keys and values of this array are:

Key Type Description
firstMatch boolean If the variable appears more than once within the Word document and firstMatch is set to true, phpdocx will only replace the first occurrence of the variable within the Word document.
target array Possible values are: document (default).
type string Possible values are:
  • block (default): replaces the variable and removes its containing paragraph.
  • inline: only replaces the variable by the WordFragment inline content (it may be used to replace a variable by formatted text).
Code samples

Example #1