Skip to content

Commit

Permalink
[+]: replace "preg_split()" with "preg_match_all()"
Browse files Browse the repository at this point in the history
  • Loading branch information
Lars Moelleken committed Feb 20, 2015
1 parent 73296da commit 34638e7
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions src/voku/helper/UTF8.php
Original file line number Diff line number Diff line change
Expand Up @@ -1197,16 +1197,9 @@ public static function split($str, $split_length = 1, $cleanUtf8 = false)
$str = self::clean($str);
}

// http://stackoverflow.com/a/8780076/369005
$ret = preg_split('/(?<!^)(?!$)/u', $str);

// HACK, while we can fix the regex
$lastChar = self::substr($str, -1);
$lastArrayElement = end($ret);
if ($lastChar != $lastArrayElement) {
array_splice($ret, -1, 1, self::substr($lastArrayElement, 1));
$ret[] = $lastChar;
}
preg_match_all('/./us', $str, $retArray);
$ret = $retArray[0];
unset($retArray);

} else {

Expand Down

0 comments on commit 34638e7

Please sign in to comment.