Hello,
UPDATE: phpdocx 9.5 added support for headers and footers in DOCXPath (https://www.phpdocx.com/documentation/introduction/docxpath), so replacements and other workflows can be done based on the header/footer position and other queries not supported by replaceVariableByText.
The replaceVariableByText method allows to use the firstMatch option with all targets. But the main document is a single XML, and the number of headers may vary. If you set firstMatch as true and the target to header (or footer), the first placeholder of each header (or footer) will be replaced.
The best approach to accomplish your task is using unique placeholders for each header (first, even, odd or per section).
Regards.