Skip to content

Instantly share code, notes, and snippets.

@ondrejmirtes
Forked from girvan/mb_str_split.php
Created May 24, 2012 07:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ondrejmirtes/2780075 to your computer and use it in GitHub Desktop.
Save ondrejmirtes/2780075 to your computer and use it in GitHub Desktop.
<?php
function mb_str_split($string,$string_length=1) {
if(mb_strlen($string) > $string_length || !$string_length) {
do {
$c = mb_strlen($string);
$parts[] = mb_substr($string,0,$string_length);
$string = mb_substr($string,$string_length);
}while(!empty($string));
} else {
$parts = array($string);
}
return $parts;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment