Get only domain name from email using PHP

Sometimes you need to extract domain name from email using PHP for whatever reason, in that case you can use code below :
PHP
  • 1
  • 2
  • 3
$email = "[email protected]"; $domain_name = substr(strrchr($email, "@"), 1); echo "Domain name is :" . $domain_name;
New question is currently disabled!