Strip/Remove IRC client control characters

Here’s a small PHP function that gets rid of the mIRC (or any other IRC client) control characters, that is the colors, underlines, italics, etc.

function stripControlCharacters($text) {
	$controlCodes = array(
		'/(\x03(?:\d{1,2}(?:,\d{1,2})?)?)/',	// Color code
		'/\x02/',								// Bold
		'/\x0F/',								// Escaped
		'/\x16/',								// Italic
		'/\x1F/'								// Underline
	);
	return preg_replace($controlCodes,'',$text);
}