It turns out that the trim() functions of PHP are even more useful than I originally thought. The trim functions ( trim(), ltrim() and rtrim() ) are normally used to trim whitespace from the ends of strings. However, the definition of trim from the PHP Manual states: “Strip whitespace (or other characters) from the beginning and end of a string”
. I added emphasis (literally) to the part that says “(or other characters)”. That means we can trim anything from a string. I hope you can see the value of this. Well, I’ll show you a brief example anyway after the fold.