gpt4 book ai didi

php - 如何使用 phpWord 和使用 cloneBlock 将变量复制到模板中

转载 作者:行者123 更新时间:2023-12-03 22:06:49 25 4
gpt4 key购买 nike

在我的应用程序中使用 phpWord,我尝试像这样在模板中克隆一个 block :

${CLONEME} <br>
You may also notice that there’s one text break (empty paragraph) before this one that can be created also by PHPWord ${item}" <br>
${/CLONEME}

在我的 php 代码中这样做: $document->cloneBlock('CLONEME', 2}

我得到:

" You may also notice that there’s one text break (empty paragraph) before this one that can be created also by PHPWord ${item}
You may also notice that there’s one text break (empty paragraph) before this one that can be created also by PHPWord ${item} "

但是 ${item} 不重复。

我想要:

" You may also notice that there’s one text break (empty paragraph) before this one that can be created also by PHPWord ${item#1} You may also notice that there’s one text break (empty paragraph) before this one that can be created also by PHPWord ${item#2} "

我该怎么做?谢谢

最佳答案

我看到了 2 种可能性:

  1. 扩展 cloneBlock 方法来做你想做的事(或者写你自己的)——看看 cloneRow 方法看看他们是如何做的 {item}->{item#1}替换
  2. cloneBlock 之后使用多个 {item} 标签并多次调用 setValue($search, $replace, 1) , 一次只能更换一个

希望对您有所帮助...

关于php - 如何使用 phpWord 和使用 cloneBlock 将变量复制到模板中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27362945/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com