Jeroen Moors


PHPWord – Line breaks
Written on 4 April 2013

Today I received an e-mail with a question, that I think, is a common issue with PHPWord: Adding line breaks in a text block.

Let’s assume you’ve got this text*:

Autumn end November: The night has fallen
The bare branches can be seen
Even more lonely

If you use a n (carriage return) or even a rn (line-feed and carriage return), your text will be shown in one single line. Don’t get misled by using LibreOffice to test your documents as it will interpret the new lines, while MS Word won’t!

A quick and easy fix to this is to replace the n by the OpenDocument tag <w:br/>:

*Credits for the haiku: Herman Van Rompuy, also known for being the President of the European Council.