PHP code example of silverslice / docx-template

1. Go to this page and download the library: Download silverslice/docx-template library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

silverslice / docx-template example snippets



use Silverslice\DocxTemplate\Template;

cx file
$template->open('test.docx')

    // replace one variable to another
    ->replace('one', 'two')

    // replace once more
    ->replace('foo', 'bar')
    
    // replace with multiline string 
    ->replaceMultiline('foo', 'one
        two
        three')

    // save docx document
    ->save('test.docx');