asterisk_hide.php $sublen) return join('', array_slice($t_string[0], $start, $sublen)); return join('', array_slice($t_string[0], $start, $sublen)); } else { $start = $start * 2; $sublen = $sublen * 2; $strlen = strlen($string); $tmpstr = '
$sublen) return join('', array_slice($t_string[0], $start, $sublen)); return join('', array_slice($t_string[0], $start, $sublen)); } else { $start = $start * 2; $sublen = $sublen * 2; $strlen = strlen($string); $tmpstr = ''; for($i=0; $i<$strlen; $i++) { if ($i>=$start && $i<($start+$sublen)) { if(ord(substr($string, $i, 1)) > 129) { $tmpstr.= substr($string, $i, 2); } else { $tmpstr.= substr($string, $i, 1); } } if (ord(substr($string, $i, 1)) > 129) $i++; } //if (strlen($tmpstr) < $strlen) $tmpstr.= "..."; return $tmpstr; } } $username = "森林生灵"; echo cut_str($username, 1, 0) .'**'. cut_str($str, 1, -1); //输出结果为:森**灵