How to hide email address and show only partail email address using PHP

How to hide email address and show only partail email address using PHP

As you notice on facebook, google etc social media, when you forgot password then they will show you partially hide email address so use can know what is my email connected with this account same thing i will give you simple example of How to Partially hide email address in PHP, So you can easily use with your php application.

Source code

Create index.php

<?php

 

functionhideEmailAddress($email)

{

if(filter_var($email, FILTER_VALIDATE_EMAIL))

{

list($first, $last)= explode('@', $email);

        $first =str_replace(substr($first,'3'),str_repeat('*',strlen($first)-3), $first);

        $last =explode('.', $last);

        $last_domain=str_replace(substr($last['0'],'1'),str_repeat('*',strlen($last['0'])-1), $last['0']);

        $hideEmailAddress= $first.'@'.$last_domain.'.'.$last['1'];

return $hideEmailAddress;

}

}

 

$email ="itsolutionstuff@gmail.com";

 

echohideEmailAddress($email);

?>


Please Share this course

It Looks like you have completed your course!! We have created Online series based on the above content. You can give a test and check your skill.




Be a Part of CollegeSpike by giving your precious comment here and help us in improving our content.