String Trim
From KlavoWiki
To strip all spaces, tabs and new lines from a string using PHP. The paramater $i is the string that will be stripped of the spaces, tabs or new lines.
$sPattern = "/\s*/m"; $sReplace = ""; preg_replace( $sPattern, $sReplace, $i );