0
<?php

$zip = new ZipArchive;
if ($zip->open('test.docx') === TRUE) {

$xmlString = $zip->getFromName('word/document.xml');
$xmlString = str_replace('$FIRST_AND_LAST_NAME', 'John Doe', $xmlString);
$zip->addFromString('word/document.xml', $xmlString);

 echo 'ok';

$zip->close();
} else {
echo 'failed';
}
?>

我曾使用此代码替换我的 docx 文件中的某些单词,但是如果我想将其保存为不同的文件名而不是替换原始文件,该怎么办?谢谢。

4

0 回答 0