feat(IndexController): 根据名字长度修改最后一位字符的处理方式

This commit is contained in:
mkm 2024-07-19 09:52:42 +08:00
parent ccad640b86
commit dd5a03ee65

View File

@ -287,7 +287,7 @@ class IndexController extends BaseLikeController
$lastStr = mb_substr($name, -1, 1); // 获取名字的最后一个字符 $lastStr = mb_substr($name, -1, 1); // 获取名字的最后一个字符
$replaceStr = ''; // 初始化替换字符串 $replaceStr = ''; // 初始化替换字符串
if ($strlen == 2) { if ($strlen == 2) {
return $firstStr . $replaceStr; return $firstStr . '*';
} else { } else {
for ($i = 0; $i < $strlen - 2; $i++) { for ($i = 0; $i < $strlen - 2; $i++) {
$replaceStr .= '*'; // 根据需要替换的字符数量,生成相应数量的星号 $replaceStr .= '*'; // 根据需要替换的字符数量,生成相应数量的星号