SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot redeyes's Avatar
    Join Date
    Dec 2001
    Posts
    102
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    splitting a string

    I am sure this is very easy but I am struggling with it.. I want to split a variable into parts.. I need the domain name only from an email address.. so how can I take someone@somewhere.com as a variable called $email, and split it so I just end up with a variable containing somewhere.com ?

    Have spent ages searching etc and about to give up!

  2. #2
    pie??? PIE!!!! rsdl's Avatar
    Join Date
    May 2001
    Location
    Vancouver, BC Canada
    Posts
    502
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you can use the explode() function

    e.g. explode("@", $email)

    see the php.net function library for more help.

  3. #3
    SitePoint Zealot redeyes's Avatar
    Join Date
    Dec 2001
    Posts
    102
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks!.. I worked it out literally seconds before I received the email notifying your reply!

    But at least you confirmed it for me

  4. #4
    "Of" != "Have" bronze trophy Jeff Lange's Avatar
    Join Date
    Jan 2003
    Location
    Calgary, Canada
    Posts
    2,063
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    $domain = explode('@', $email, 2);
    $domain = $domain[1];
    That should do what you want.
    Who walks the stairs without a care
    It shoots so high in the sky.
    Bounce up and down just like a clown.
    Everyone knows its Slinky.


Bookmarks

Posting Permissions

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