Skip to content

Instantly share code, notes, and snippets.

@mlabrum
Created July 21, 2010 07:10
Show Gist options
  • Save mlabrum/484183 to your computer and use it in GitHub Desktop.
Save mlabrum/484183 to your computer and use it in GitHub Desktop.
#splits a string into parts, and returns them, this uses a workaround to handle wide unicode characters
function unicode_split($str, $length){
if(preg_match_all("/./u", $str, $results)){
$splits = Array_chunk($results[0], $length);
$str_splits = Array();
foreach($splits as $split){
$str_splits[] = implode("", $split);
}
return $str_splits;
}else{
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment