Update src/PHPWord/Template.php
This function returns array of all variables in template.
Test code:
$PHPWord = new PHPWord();
$document = $PHPWord->loadTemplate('Template.docx');
var_dump($document->getVariables());
This commit is contained in:
parent
4f457c99e6
commit
9d6b2ff7bd
@ -91,7 +91,14 @@ class PHPWord_Template {
|
|||||||
|
|
||||||
$this->_documentXML = str_replace($search, $replace, $this->_documentXML);
|
$this->_documentXML = str_replace($search, $replace, $this->_documentXML);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Returns array of all variables in template
|
||||||
|
*/
|
||||||
|
public function getVariables()
|
||||||
|
{
|
||||||
|
preg_match_all('/\$\{(.*?)}/i', $this->_documentXML, $matches);
|
||||||
|
return $matches[1];
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Save Template
|
* Save Template
|
||||||
*
|
*
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user