$len) { $start = 1; } if ($end != 0 && $end > $len) { $end = $len - 2; } $endStart = $len - $end; $top = mb_substr($str, 0, $start, $charset); $bottom = ""; if ($endStart > 0) { $bottom = mb_substr($str, $endStart, $end, $charset); } $len = $len - mb_strlen($top, $charset); $len = $len - mb_strlen($bottom, $charset); $newStr = $top; for ($i = 0; $i < $len; $i++) { $newStr .= $dot; } $newStr .= $bottom; return $newStr; } }