0

PHP 隐藏电话号码中间四位, 替换为*

john created at5 years ago view count: 2444
report
回复
0
   function addMask($val, $mask)
    {
        if ($val != NULL || $val != "") {
            $masked = '';
            $k = 0;
            for ($i = 0; $i <= strlen($mask) - 1; $i++) {
                if ($mask[$i] == '#') {
                    if (isset($val[$k])) $masked .= $val[$k++];
                } else {
                    if (isset($mask[$i])) $masked .= $mask[$i];
                }
            }
        } else {
            $masked = NULL;
        }
        return $masked;
    }
     echo addMask("17902011111", "#####****####");
5 years ago 回复

Recent search keywords