Util.php 436 B

1234567891011121314151617
  1. <?php
  2. namespace addons\yexam\library;
  3. class Util
  4. {
  5. public static function str_split_unicode($str, $l = 0) {
  6. if ($l > 0) {
  7. $ret = array();
  8. $len = mb_strlen($str, "UTF-8");
  9. for ($i = 0; $i < $len; $i += $l) {
  10. $ret[] = mb_substr($str, $i, $l, "UTF-8");
  11. }
  12. return $ret;
  13. }
  14. return preg_split("//u", $str, -1, PREG_SPLIT_NO_EMPTY);
  15. }
  16. }