Extract domain and extension from email

Posted on 2005-04-07
Last Modified: 2006-11-18
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 "" from "".

Many thanks!
Question by:wjdashwood
    LVL 32

    Accepted Solution

    If the string is only the email-address, then you could use explode

    $string = "";
    $items = explode("@",$string);

    $name = $items[0]; //Someone
    $domain = $items[1]; //

    Author Comment

    Thanks Batalf, works a treat!

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    As this topic comes over and over again in different forms, I've finally decided to write a short (yea, right...) article / tutorial about pagination with PHP with MySQL database. There are dozens of these kind of tutorials, I know - I wanted to mak…
    I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
    The viewer will learn how to dynamically set the form action using jQuery.
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now