Hide Email or Phone with star symbol / mark / *

Srinivas Gundale
Jan 30 · 1 min read

public function cf_hideEmailPhone($country_code,$phone,$email){

$strLength=strlen($phone);

if($strLength==10){

$repeat = str_repeat(“*”,$strLength-3);

$last_dif=substr($phone, 7, 9);

$dispPhone = $country_code.$repeat.$last_dif;

}else if($strLength==9){

$repeat = str_repeat(“*”,$strLength-3);

$last_dif=substr($phone, 6, 8);

$dispPhone = $country_code.$repeat.$last_dif;

//$dispPhone = $user->country_code.str_repeat(“*”,$strLength-2);

}

$email_str= explode(“@”,$email);

$dispEmail = substr($email_str[0], 0, 3).str_repeat(“*”, strlen($email_str[0])-3).”@”.$email_str[1];

$returnData[‘dispPhone’]=$dispPhone;

$returnData[‘dispEmail’]=$dispEmail;

return $returnData;

}

public function cf_hideEmail($email){

$email_str= explode(“@”,$email);

$dispEmail = substr($email_str[0], 0, 3).str_repeat(“*”, strlen($email_str[0])-3).”@”.$email_str[1];

$returnData[‘dispEmail’]=$dispEmail;

return $returnData;

}

public function cf_hidePhone($country_code,$phone){

$strLength=strlen($phone);

if($strLength==10){

$repeat = str_repeat(“*”,$strLength-3);

$last_dif=substr($phone, 7, 9);

$dispPhone = $country_code.$repeat.$last_dif;

}else if($strLength==9){

$repeat = str_repeat(“*”,$strLength-3);

$last_dif=substr($phone, 6, 8);

$dispPhone = $country_code.$repeat.$last_dif;

}

$returnData[‘dispPhone’]=$dispPhone;

return $returnData;

}