A fresh mix of code snippets and tutorials

PHP Stringify Formatted Text

This code snippet takes a string of text and removes all carriage returns, new lines, and tabs, replacing any matches with a simple blank space. An ideal way to “stringify” a potentially formatted lump of alphanumeric text.

Quick Fix Willis

Takes a lump of formatted text and turns it into a clean string:

// stringify formatted text
$filtered = trim(preg_replace('/[\r\n\t ]+/', ' ', $filtered));

A nice little snippet to have in the toolbox.

★ Pro Tip: