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 4 - Strip Whitespace

A few of the plug-ins in this book are really short and sweet and, at just a single line of code, this is one of them. But although it's tiny it packs a punch because it can clean up the messiest text by removing all the whitespace in a string such as extra spaces, tabs, newlines and so on.

The Figure shows part of the US Declaration of Independence as it might appear if read in from a poor quality reprint by some optical character recognition software, followed by the result of running the text through this plug-in.