0

Good Morning Guys! I need to get an e-mail from my database, but I'd like to show it like that:

some*******@hotmail.com

I'd like to show the beginning of my e-mail and then everything after @.

I'm using the following code:

$user_email= "********".substr($linha3['user_email'], -8);

It's working, but sometimes It doesn't appear in a nice way:

********mail.com

May you help me with any solution?

Rotimi
  • 4,783
  • 4
  • 18
  • 27
Lucas Fusco
  • 75
  • 1
  • 8

2 Answers2

2

$email = $linha3['user_email'];

$email= substr($email, 0, 3).'****'.substr($email, strpos($email, "@"));

Ranjith
  • 165
  • 15
2

Use RegEx to always match the e-mail username :

echo preg_replace('/.*@/', '***@', 'some_mail@somewhere.net');