I have a simple task to do with PHP, but since I\'m not familiar with Regular Expression or something... I have no clue what I\'m going to do.
what I want is very si
For e-mails, this function preserves first letter:
function hideEmail($email)
{
$parts = explode('@', $email);
return substr($parts[0], 0, min(1, strlen($parts[0])-1)) . str_repeat('*', max(1, strlen($parts[0]) - 1)) . '@' . $parts[1];
}
hideEmail('hello@domain.com'); // h****@domain.com
hideEmail('hi@domain.com'); // h*@domain.com
hideEmail('h@domain.com'); // *@domain.com