From 51b17a30592fdf49c40cfd2d0354345c9b8d34ec Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Wed, 11 Sep 2019 11:58:56 +0900 Subject: [PATCH] Update string.utils.php --- helper/string.utils.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/helper/string.utils.php b/helper/string.utils.php index 0d5e7a4..a1121e1 100644 --- a/helper/string.utils.php +++ b/helper/string.utils.php @@ -96,12 +96,17 @@ if(!check_function_exists("get_splitted_strings")) { $_len = get_string_length($str); $_pos = 0; - while($_len > $_pos) { - $strings[] = get_cutted_string($str, $_pos, $len, $charset); - $_pos += $len; - - if($_pos >= $_len) { - $strings[] = get_cutted_string($str, $_pos); + if($len >= $_len) { + $strings[] = $str; + } else { + $__len = ceil($_len / $len); + for($i = 0; $i < $__len; $i++) { + $_pos = $len * $i; + $strings[] = get_cutted_string($str, $_pos, $len, $charset); + } + + if($_len - $_pos > 0) { + $strings[] = $strings[] = get_cutted_string($str, $_pos); } }