1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to split a string in php twice.... Help

Discussion in 'Programming' started by Jangga, Mar 11, 2017.

Tags:
  1. Jangga

    Jangga Junior Member

    Joined:
    Aug 8, 2016
    Messages:
    123
    Likes Received:
    4
    Gender:
    Male
    Occupation:
    Freelancer: A reWriter
    Location:
    Africa
    Hello guys, I would love to split a string(an email) such that I would be able to get the 'gmail' or 'yahoo' or 'outlook' out of it

    What I got now:
    Code:
    $geta=explode('.', [email protected]);
    $getb=explode('@', $geta["0"]);
    echo $get["1"]:
    
    But it ain't working
     
  2. cheva

    cheva Regular Member

    Joined:
    Aug 22, 2009
    Messages:
    349
    Likes Received:
    404
    Location:
    Aiur
    $parts = explode("@", "[email protected]");
    $username = $parts[0];
    $domain = $parts[1];

    $e = explode(".", $domain);

    echo $e[0];
     
    • Thanks Thanks x 1
  3. Jangga

    Jangga Junior Member

    Joined:
    Aug 8, 2016
    Messages:
    123
    Likes Received:
    4
    Gender:
    Male
    Occupation:
    Freelancer: A reWriter
    Location:
    Africa
    Thanks alot man
     
  4. cheva

    cheva Regular Member

    Joined:
    Aug 22, 2009
    Messages:
    349
    Likes Received:
    404
    Location:
    Aiur
    no worries dude
     
    • Thanks Thanks x 1