Sample 23 TemplateBlock

04:25:34 Creating new TemplateProcessor instance...
04:25:34 Saving the result document...
04:25:34 Done writing file(s)
04:25:34 Peak memory usage: 2 MB

 

Results: docx


<?php

include_once 'Sample_Header.php';

// Template processor instance creation
echo date('H:i:s') , ' Creating new TemplateProcessor instance...' EOL;
$templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor('resources/Sample_23_TemplateBlock.docx');

// Will clone everything between ${tag} and ${/tag}, the number of times. By default, 1.
$templateProcessor->cloneBlock('CLONEME'3);

// Everything between ${tag} and ${/tag}, will be deleted/erased.
$templateProcessor->deleteBlock('DELETEME');

echo 
date('H:i:s'), ' Saving the result document...'EOL;
$templateProcessor->saveAs('results/Sample_23_TemplateBlock.docx');

echo 
getEndingNotes(['Word2007' => 'docx'], 'Sample_23_TemplateBlock');
if (!
CLI) {
    include_once 
'Sample_Footer.php';
}