Skip to content

Instantly share code, notes, and snippets.

@ayhaadam
Created August 29, 2018 16:45
Show Gist options
  • Save ayhaadam/c713f26fc779a26f2365c6d09dba1aff to your computer and use it in GitHub Desktop.
Save ayhaadam/c713f26fc779a26f2365c6d09dba1aff to your computer and use it in GitHub Desktop.
Mask (cell) phone number with asterisk
function mask_cell($cell) {
$cell_array = explode(' ', $cell);
$length = count($cell_array);
$masked = '';
for ($i = 0; $i < count($cell_array); $i++) {
if ($i != ($length - 2)) {
$masked .= $cell_array[$i];
} else {
$masked .= str_repeat('·', strlen($cell_array[$i]));
}
if ($i != ($length - 1)) {
$masked .= '-';
}
}
return $masked;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment