Forum


Replies: 4   Views: 6664
Replace template variable with text containing new line
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by lorepra  · 11-04-2013 - 12:13

If I have it right, you can use replaceTemplateVariableByHTML, converting line feed to < /br>,

[code]
$text='first line
second line';

$text=str_replace("\n",'\n',$text);

$text=str_replace('\n','<br />',$text);

$parHTML=array('isFile' => false, 'parseDivsAsPs' => true,'downloadImages' => false);

$docx->replaceTemplateVariableByHTML('templateVariable','inline',$text,$parHTML);
[/code]

Regards,