PHP code shows how to replace email address with asterisk(*). The script used for partially hide email address with asterisk (*).
<?php /** * Hide email address with asterisk(*) * * @param $email * @reeturn $email with asterisk(*) // t***********l@g*****l.com * */ function hideEmail($email) { $mail_segments = explode("@", $email); $mail_segments[0] = substr($mail_segments[0], 0, 1) . str_repeat("*", strlen($mail_segments[0]) - 2) . substr($mail_segments[0], -1); $pos = strpos($mail_segments[1], '.'); $mail_segments[1] = substr($mail_segments[1], 0, 1) . str_repeat("*", strlen($mail_segments[1]) - $pos+1) . substr($mail_segments[1], $pos-1); return implode("@", $mail_segments); } /** call function and display result **/ echo hideEmail("testingdhaval@gmail.com"); ?>
No comments:
Post a Comment