acabo de crear un codigo, me parecio interesante una funcion que haga eso, te dejo el codigo aca:
Código PHP:
Ver original/* censor mail by kspr :PP */
function censor_email($email = ''){
// TODO: check email
// email string
$email = $email;
// search important email parts
preg_match('~([^@]+)@([^\.]+)((\.[^$]+)+)~', $email, $email_parts);
// get prefix email
// get 40% of email
$percent = 40; // change it or not :)
// calcule percent
$prefix_percent = (strlen($email_parts[1]) * $percent) / 100;
// set prefix email
$prefix_email = substr($email, 0, $prefix_percent) . str_repeat('*', strlen($email_parts[1])-($prefix_percent-1));
// set suffix
// set new email string
$new_email = $prefix_email . '@' . $suffix_email;
return $new_email;
}
));
retorna:
Código HTML:
Ver originalarray(4) {
[0]=>
string(25) "ksp******@***********.com"
[1]=>
string(11) "k***@**.net"
[2]=>
string(25) "jonat*********@******.net"
[3]=>
string(38) "whiitewhiit*****************@*****.com"
}