almost 6 years ago

## PHP: Text trimming, value dumping and MIME encoding

While working on various web projects written completely in PHP, I collected
some custom procedures for more satisfying work.

### Text trimming

Often you are in need of trimming some text by set number of characters, but
do not want to trim mid-word. This is a function which cuts text between words
trying to reduce string length to be less than provided value.

### Pretty-printing values of variables

So, you are a web developer. Why are you have to use such stdout-oriented
functions as echo or print? We will dump variables of any complexity using
HTML format.

to colorize the output if it is sufficiently complex.

### MIME encoding of strings

When sending e-mail letters in real multi-national world you need to declare
character encoding on almost anything. To do this in e-mail headers, you should
wrap your header content in special encoding declaration and convert it to
Base64. To speed-up this process, I wrote small helper function.

Inspired by comment to mb_encode_mimeheader() at php.net.