Answer the question
In order to leave comments, you need to log in
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
$slovo=preg_replace('/([a-z0-9]{1})(.*?)([a-z0-9]{2}@...)/ism' "$1***$3", $slovo);
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);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question