Skip to content

Commit

Permalink
手机号和名字,中间*代替
Browse files Browse the repository at this point in the history
  • Loading branch information
Joycezhangw committed Dec 14, 2020
1 parent b8bd939 commit 5f667cb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Helpers/FiltersHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public static function filterRank($num = 0)
*/
public static function filterMobile($mobile)
{
return substr($mobile, 0, 5) . "****" . substr($mobile, 9, 2);
return preg_replace("/(\d{3})\d{4}(\d{4})/", "\$1****\$2", $mobile);
}

/**
Expand Down Expand Up @@ -151,7 +151,7 @@ public static function subStrCut(string $str, $head = 1, $foot = 1)
$strLen = mb_strlen($str, 'UTF-8');
$firstStr = mb_substr($str, 0, $head, 'UTF-8');
$lastStr = mb_substr($str, -$foot, $foot, 'UTF-8');
return $strLen == 2 ? $firstStr . str_repeat('*', 3) : $firstStr . str_repeat("*", 3) . $lastStr;
return $strLen == 2 ? $firstStr . str_repeat('*', 1) : $firstStr . str_repeat("*", $strLen - 2) . $lastStr;
}

/**
Expand Down

0 comments on commit 5f667cb

Please sign in to comment.