I have the current code where I'm trying to mask part of user's email with ***
$user_email = [email protected]
$unmasked_user_email_array = explode('@', $user_email);
$unmasked_user_email_string = $unmasked_user_email[0];
$unmasked_user_email_string_length = strlen($unmasked_user_email_string);
if ($unmasked_user_email_string_length > 4) {
replace the last three characters of $unmasked_user_email_string with ***
}
else if ($unmasked_user_email_string_length < 5) {
replace the last two characters of $unmasked_user_email_string with **
}
else if ($unmasked_user_email_string_length < 4) {
replace the last one character of $unmasked_user_email_string with *
}
My question is, what methods or functions should I use to be able to accomplish what I'm trying to do?
Thanks