Created
July 31, 2014 06:23
-
-
Save xtfer/686ad2ea3bcab505502b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Trim all odd characters. | |
* | |
* Character Decimal Use | |
* "\0" 0 Null Character | |
* "\t" 9 Tab | |
* "\n" 10 New line | |
* "\x0B" 11 Vertical Tab | |
* "\r" 13 New Line in Mac | |
* " " 32 Space | |
* | |
* @param string $str | |
* the string to trim | |
* | |
* @return string | |
* The trimmed string. | |
*/ | |
public function trimAll($str) { | |
$what = "\\x00-\\x20"; | |
return trim(preg_replace("/[" . $what . "]+/", ' ', $str), $what); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment