addCrossReference

addCrossReference

TRIAL / ADVANCED / PREMIUM

Inserts a cross-reference into the Word document.

Description
public addCrossReference (string $text, [array $options = array()] )

This method allows the insertion of cross-references into a Word document.

Parameters
Key Type Description
text string Text of the reference

options

The options array includes the following keys and values:

Key Type Description
type string The bookmark type. Possible values are 'bookmark' and 'heading'.
modifiers string Custom modifiers: \r \h, \n \h....
referenceName string The name of the element to be referred.
referenceTo string Content to display when the field is updated PAGEREF (default, page number), REF (bookmark text content), ABOVE_BELOW (above/below text).

Other styles from addText can also be used.

Code samples

Example #1

The resulting Word document looks like:

Release notes
  • phpdocx 10.0:
    • modifiers and referenceTo options.
  • phpdocx 8.0:
    • new styles.
  • phpdocx 6.0:
    • new method.