Created
December 5, 2017 01:22
-
-
Save yeungon/1fd4d754f72b0f21a6d25a984010096e to your computer and use it in GitHub Desktop.
split unicode/vietnamese string
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
function str_split_unicode($str, $l = 0) { | |
if ($l > 0) { | |
$ret = array(); | |
$len = mb_strlen($str, "UTF-8"); | |
for ($i = 0; $i < $len; $i += $l) { | |
$ret[] = mb_substr($str, $i, $l, "UTF-8"); | |
} | |
return $ret; | |
} | |
// hàm preg_split thuộc nhóm xử lý text bằng REGEX http://php.net/manual/en/ref.pcre.php | |
return preg_split("//u", $str, -1, PREG_SPLIT_NO_EMPTY); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment