function func_substr_replace($str, $replacement = '*', $start = 1, $length = 3) { $len = mb_strlen($str,'utf-8'); if ($len > intval($start+$length)) { $str1 = msubstr($str,0,$start); $str2 = msubstr($str,intval($start+$length),NULL); } else { $str1 = msubstr($str,0,1); $str2 = msubstr($str,$len-1,1); $length = $len - 2; } $new_str = $str1; for ($i = 0; $i < $length; $i++) { $new_str .= $replacement; } $new_str .= $str2; return $new_str; }