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

Hi, I have resolved this way:

$testo='First line
Second line';
$testo=lf2lf($testo);
$aTesto=explode('\\n',$testo);
foreach ($aTesto as $testo) {
$docx->addText($testo);
}

function lf2lf($text) {
$return=str_replace("\\n",'\\n',$text);
$return=str_replace("\\r\\n",'\\n',$return);
return $return;
}

Hope this help,