3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function mask_email($email, $masks = 5) { $array = explode("@", $email); $string_length = strlen($array[0]); if ($string_length < $masks) $masks = $string_length; $result = substr($array[0], 0, -$masks) . str_repeat('*', $masks); return $result."@".$array[1]; } echo mask_email("tesasdasdasdt@test.com")."\n"; echo mask_email("longeremail@test.com")."\n"; echo mask_email("longeremail@test.com", 2)."\n";
based on pQkHe
Output for 5.6.0 - 5.6.30, hhvm-3.18.5 - 3.22.0, 7.0.0 - 7.3.0beta1
tesasdas*****@test.com longer*****@test.com longerema**@test.com