How to hide an email before @ in php?

If you are looking for a function in which you want a code to hide email before @ so just copy and paste this code.

function hide_mail($email) {
    $mail_part = explode("@", $email);
    $mail_part[0] = str_repeat("*", strlen($mail_part[0]));
    return implode("@", $mail_part);
}

Pass email id in it and this will hide the email before @

// *************@gmail.com

Comments