A McGraw Hill Book Plug-in PHP: 100 Power Solutions
By Robin Nixon (McGraw Hill 2010, ISBN 978-0071666596)

Home | About | Buy It | Download | Contact

Select Chapter: 1  2  3  4  5  6  7  8  9 10 11 12

Chapter 3: Plug-in 1 - Wrap Text

There are various ways you can make text wrap in a browser, including using tables, iframes, and textareas, but there are times when you need absolute control over the wrapping in terms of the number of characters at which the wrap should occur, regardless of whether the user resizes their browser window.

Using this plug-in it's easy to pass a string of text and have it wrapped using <br /> tags. What's more it can also indent the start of a each paragraph by an amount of your choosing.

The Figure shows the opening paragraphs of Charles Dickens' Oliver Twist, with a wrap width of 71 characters, and a paragraph indent setting of 5 characters.