V
V
Valeri Lavrov2015-11-11 17:34:39
PHP
Valeri Lavrov, 2015-11-11 17:34:39

How to hide part of email using php?

Email is taken from the database and displayed on the screen, how to hide part of the address?
For example, in the database there is "[email protected]", but it is necessary that it would display "p***[email protected]" I was
surprised that Google did not give answers, except
$slovo=substr($slovo,0, (strlen($slovo)-1) );

Answer the question

In order to leave comments, you need to log in

3 answer(s)
O
Optimus, 2015-11-11
Pyan @marrk2

$slovo=preg_replace('/([a-z0-9]{1})(.*?)([a-z0-9]{2}@...)/ism' "$1***$3", $slovo);

K
kompi, 2015-11-11
@kompi

Leaves only the first and last character before @ unclosed:

$email = '[email protected]';
$length = strpos($email, '@') - 2;
$asterisk = '*';
for($i = 1; $i < $length; $i++)
  $asterisk .= '*'; 
$email = substr_replace($email, $asterisk, 1, $length);

A
Andrew, 2015-11-11
@R0dger

Badly searched - stackoverflow.com/questions/20545301/partially-hid...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question