Skip to content

nguyenhiepvan/docxfindandreplace

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DOCX Find & Replace

This is a simple find and replace utility for DOCX files. Simple way to take a DOCX template, map some variables, and save a new copy.

Installation

Via Composer

$ composer require nguyenhiep/docxfindandreplace

Usage

In your DOCX template you will need to wrap any variables you would like to replace with curly braces (e.g. firstname). You can use regex expressions as key

\Nguyenhiep\DocxFindAndReplace\Docx::create(__DIR__ . "/template.docx")->replace(
    [
        "firstname"                                         => "nguyen",
        "lastname"                                          => "hiep",
        "/[-0-9a-zA-Z.+_]+@[-0-9a-zA-Z.+_]+.[a-zA-Z]{2,4}/" => "[email protected]"
    ]
)->save(__DIR__ . '/newfile.docx');

About

Find and replace variables in a DOCX template.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%