3v4l.org

run code in 300+ PHP versions simultaneously
<?php function maskString($string) { return preg_replace('/(?<=.).(?=.*)/u','*',$string); } function maskEmail($email) { $arremail = explode('@',$email); $arrdomain = explode('.',$arremail[1]); $jumdomain = count($arrdomain); $dom = array(); for($i=0; $i<$jumdomain-1; $i++) { $dom[] = maskString($arrdomain[$i]); } $domain = implode('.',$dom); //$email1 = preg_replace('/(?<=.).(?=.*@)/u','*',$arremail[0].'@'); //$email2 = preg_replace('/(?<=.).(?=.*[.])/u','*',$arremail[1]); //return $email1.$email2; return maskString($arremail[0]).'@'.$domain; } $email = 'facebook@yahoo.co.id'; $result = maskEmail($email); echo $result;
Output for git.master, git.master_jit, rfc.property-hooks
f*******@y****.c*

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
63.63 ms | 401 KiB | 8 Q