I have dynamically generated email id
say testing1234.gjj@gmail.com
.
I want to convert email id to xxxxxxxxxx.xxx@gmail.com
.
Please tell me how can i implement this in php for any email address .
Try with following simple way, by using explode() function you will get email domain and you can easily append that domain to new email address as follow.
<?php
$strEmail = "testing1234.gjj@gmail.com";
$arrEamil = explode("@", $strEmail);
$arrReverse = array_reverse($arrEamil);
$strEamilDomain = $arrReverse[0];
if ($strEamilDomain != "") {
$strNewEmail = "xxxxxxxxxx.xxx@".$strEamilDomain;
}
echo $strNewEmail;
?>
Try this one (if you want to replace all letters by 'x')
$myMail = 'testing1234.gfhhfdhg@gmail.com';
$myMailArray = str_split($myMail);
for ($i = 0; $i < count($myMailArray); $i++) {
switch ($myMailArray[$i]) {
case '@':
break 2;
case '.':
break;
default:
$myMailArray[$i] = 'x';
}
}
$mailAnon = implode($myMailArray);
echo $mailAnon;