Wrapping words for a perfect typography
Wrapping words for a perfect typography.
This library is made for the use with Composer. Add it to your project by running
$ composer req bitandblack/word-wrapper.
This wrappers are available:
LinesWrapper: This class divides a sentence to reach a given number of lines.
MaxLengthWrapper: This class wraps a sentence when a lines reaches the maximum length of characters.
This outputs are available:
CSSOutput: This class uses
<span>to divide the lines. Each
class="word-wrapper-line"which you can use to define a wrap by your own. For example
white-space: nowrapis very useful here. It's possible to customize the tag.
HTMLOutput: This class uses
<br>to wrap into new lines. It's possible to customize the tag.
CustomOutput: This class needs to know your custom string. This is the second parameter.
This example makes use of the
LinesWrapper and the
<?php use BitAndBlack\WordWrapper\Output\HTMLOutput; use BitAndBlack\WordWrapper\Wrapper\LinesWrapper; $sentence = 'The Lord of the Rings'; $wrapper = new LinesWrapper(2, $sentence); echo new HTMLOutput($wrapper);
This will echo
The Lord of <br>the Rings.
If you have questions feel free to contact us under