Marcos Wendel Marcos Wendel - 4 months ago 34
PHP Question

How to add a textbreak in phpword?

I use the "phpword" class to generate a .doc file, but i have the problem:

how to add a line break for this problem?, so for example I have the following text:

Code (in a variable):

"This is

a text

With line break"

Now if we enter that into the word document...will display this:

"This is a text With line break."

how can i do this? i want the text in the word document with this style:

This is

a text

With line break



This is not possible with phpword. You have to split the string in lines and use addTextBreak.

$text = "This is
a text
With line break";

$lines = explode("\n", $text);

foreach ($lines as $line) {