分类:PHP 发布时间:2023-02-13 10:05:51
``` public function stringDesensitization($string, $start = 0, $length = 0, $re = '*') { if (empty($string)) { return false; } $strarr = array(); $strlen = mb_strlen($string); for ($i = 0; $i < $strlen; $i++) { $strarr[] = mb_substr($string, $i, 1); } $begin = $start >= 0 ? $start : ($strlen - abs($start)); $end = $strlen - 1; if ($length > 0) { $end = $begin + $length - 1; } elseif ($length < 0) { $end -= abs($length); } for ($i = $begin; $i <= $end; $i++) { $strarr[$i] = $re; } return implode('', $strarr); } ```
搜索
文章分类
最新文章