[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 271
  • Last Modified:

Extract domain and extension from email

Sorry if this has been asked before but I just want a little bit of PHP to extract the domain and extension from an email address. For example, I want "hotmail.com" from "somebody@hotmail.com".

Many thanks!
0
wjdashwood
Asked:
wjdashwood
1 Solution
 
BatalfCommented:
If the string is only the email-address, then you could use explode

$string = "someone@hotmail.com";
$items = explode("@",$string);

$name = $items[0]; //Someone
$domain = $items[1]; // hotmail.com
0
 
wjdashwoodAuthor Commented:
Thanks Batalf, works a treat!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now