Marcos Wendel Marcos Wendel - 1 year ago 203
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


Answer Source

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) {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download