用PHPWord setValue函数替换html实体

时间:2014-09-04 06:23:05

标签: javascript php xml codeigniter phpword

我在PHPWord中遇到setValue()函数的问题。通常,参数应该是纯文本变量,但在这种情况下我必须处理一个html块。并且PHPWord无法将html标记解析为单词xml。

我的意思是替换这个html: enter image description here

进入Word模板: enter image description here

要像这样输出: enter image description here

有没有解决方案?

1 个答案:

答案 0 :(得分:-2)

在设置var之前,您可以使用utf8_decode或htmlentities函数。 例如:

$document->setValue('cif', utf8_decode($cif));
$document->setValue('cif', htmlentities($cif));