Created
February 2, 2021 15:03
-
-
Save decodedmrq/8e07d1c98b67250c3dd5a79b4eabb0fd to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/** | |
* Remove space fullsize | |
* | |
* @param string $str string before remove | |
* @return string after removed | |
*/ | |
public static function mb_trim($str, $chars = '\s ') { | |
$str = preg_replace("/^[$chars]+/u", '', $str); | |
$str = preg_replace("/[$chars]+$/u", '', $str); | |
return $str; | |
} | |
or | |
/** | |
* Trim space, tab | |
* @param string $value | |
* @return string | |
*/ | |
public function trimSpace($value) { | |
mb_internal_encoding('UTF-8'); | |
mb_regex_encoding('UTF-8'); | |
$value = mb_ereg_replace("^[\n\r\s\t ]+", '', $value); | |
$value = mb_ereg_replace("[\n\r\s\t ]+$", '', $value); | |
$value = trim($value); | |
return $value; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment