I thought of crafting in a very simple way using the function substr_replace combined with strpos.
Behold:
$mail = '[email protected]'
substr_replace($mail, '*****', 1, strpos($mail, '@') - 2); 
The Result is
'w*****[email protected]'
The explanation of the code is as follows: the third argument (1) makes the position to be replaced from the first character. The fourth argument strpos($mail, '@') will give us the final position where it should be replaced, which is the @. In that case, I used the -2 so that neither the @ nor the last character before it was replaced. 
The size of the replacement will be determined from the initial position. If it was necessary to display 2 characters at the beginning and 2 before the @, we would have to change the function as follows:
substr_replace($mail, '*****', 2, strpos($mail, '@') - 4); 
							
							
						 
PS: I thought maybe using the
substr_replacewas a good idea– Wallace Maxters