From 9d6b2ff7bd1b762acf7b5a0967ad48a3d9251bcf Mon Sep 17 00:00:00 2001 From: SergeC Date: Sat, 11 Aug 2012 23:02:57 +0300 Subject: [PATCH] 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()); --- src/PHPWord/Template.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/PHPWord/Template.php b/src/PHPWord/Template.php index 150676f779..832776c3ab 100644 --- a/src/PHPWord/Template.php +++ b/src/PHPWord/Template.php @@ -91,7 +91,14 @@ public function setValue($search, $replace) { $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 *