- preg_match: documentation ( source)
- str_pad: documentation ( source)
<?php
$mail = "Test@test.com";
preg_match("/(.)(.*?)@(.*)/", $mail, $Match);
$str = $Match[1] . str_pad("", strlen($Match[2]), "*"). "@" . str_pad("", strlen($Match[3]), "*");
echo $str;