How to Partially hiding an email address using PHP regex

In this tutorial, I will show you how to email address partially using PHP regex. Many PHP project needs this type of specialty. I want to display email from a database and I want to only show some character not an all

PHP Code

<?php
$email = 'youremailaddrss@website.com';
echo $email = preg_replace('/(?:^|@).\K|\.[^@]*$(*SKIP)(*F)|.(?=.*?\.)/', '*', $email);
?>

Output

y************@w*****.com

And if you like these tutorials please share it with your friends via Email or Social Media.

Leave a Reply

Your email address will not be published. Required fields are marked *