Skip to content

Commit 4f514d2

Browse files
author
Dave Gudgeon
committed
Load any number of headers and footers
1 parent 763de34 commit 4f514d2

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/PhpWord/Template.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,17 @@ public function __construct($strFilename)
7575
$this->_objZip = new $zipClass();
7676
$this->_objZip->open($this->_tempFileName);
7777

78-
// Find and load up to three headers and footers
79-
for ($i = 1; $i <= 3; $i++) {
80-
$headerName = $this->getHeaderName($i);
81-
$footerName = $this->getFooterName($i);
82-
if ($this->_objZip->locateName($headerName) !== false) {
83-
$this->_headerXMLs[$i] = $this->_objZip->getFromName($headerName);
84-
}
85-
if ($this->_objZip->locateName($footerName) !== false) {
86-
$this->_footerXMLs[$i] = $this->_objZip->getFromName($footerName);
87-
}
78+
// Find and load headers and footers
79+
$i = 1;
80+
while ($this->_objZip->locateName($this->getHeaderName($i)) !== false) {
81+
$this->_headerXMLs[$i] = $this->_objZip->getFromName($this->getHeaderName($i));
82+
$i++;
83+
}
84+
85+
$i = 1;
86+
while ($this->_objZip->locateName($this->getFooterName($i)) !== false) {
87+
$this->_footerXMLs[$i] = $this->_objZip->getFromName($this->getFooterName($i));
88+
$i++;
8889
}
8990

9091
$this->_documentXML = $this->_objZip->getFromName('word/document.xml');

0 commit comments

Comments
 (0)