Results 1 to 10 of 10
  1. #1

  2. #2
    Join Date
    May 2004
    Posts
    500
    $string = [email protected]';
    $new = explode('@',$string);
    $domain = $new[0];
    echo $domain;

    Will echo everything after the @ sign.

  3. #3
    I'm embarrased by how easy that was and that I should have known. Thanks though, I appreciate it. Hopefully not too many people read this thread

  4. #4
    Join Date
    Jan 2003
    Posts
    1,715
    You can even assign directly to the domain:
    $string = [email protected]';
    list($domain) = explode('@',$string);
    echo $domain;
    Game Servers are the next hot market!
    Slim margins, heavy support, fickle customers, and moronic suppliers!
    Start your own today!

  5. #5
    Excellent. Thanks for the tips

  6. #6
    Join Date
    Jan 2005
    Posts
    45
    Is something wrong with my PHP install? Both of those examples print out "user" instead of "domain.com" ... using

    $string = [email protected]';
    list($user, $domain) = explode('@',$string);
    echo $domain;

    prints correctly. This just me?

  7. #7
    I get user too, and that's what I wanted. Not sure if it's supposed to do the opposite.

  8. #8
    Join Date
    Jan 2005
    Posts
    45
    Sorry, when mouldy_punk said "Will echo everything after the @ sign." and it didn't I got confused. My mistake.

  9. #9
    Join Date
    Jan 2003
    Posts
    1,715
    Yup, the variable was misnamed. The OP asked for the front portion, which the code did return, and your code gives both sides.
    Game Servers are the next hot market!
    Slim margins, heavy support, fickle customers, and moronic suppliers!
    Start your own today!

  10. #10
    Join Date
    May 2004
    Posts
    500
    Heh, sorry, typo.

    Change this line;
    $domain = $new[0];
    To;
    $domain = $new[1];

    That will echo everything after the @ sign.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •