Need help PHP Gurus!

Discussion in 'PHP' started by geekos, Apr 30, 2010.

  1. #1
    Hi

    I have a list of email on my DB and I want only to show the name before the @ symbol
    ex:
    ---will become----> username (all characters before @ symbol will only display)

    I hope someone will help me

    TIA!
     
    geekos, Apr 30, 2010 IP
  2. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #2
    <?php
    $email = "username@gmail.com";
    $arr = explode("@", $email);
    //outputs username...
    echo $arr[0];
    ?>
    
    PHP:
     
    danx10, Apr 30, 2010 IP
  3. FriendSwapMeet.com

    FriendSwapMeet.com Peon

    Messages:
    67
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    <?php
    $string = "j@j.com";
    $token = strtok($string, "@");

    while ($token != false)
    {
    echo "$token<br />";
    $token = strtok("@");
    } ?>
     
    FriendSwapMeet.com, Apr 30, 2010 IP
  4. geekos

    geekos Well-Known Member

    Messages:
    3,365
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    140
    #4
    It works leike a charm! Thank you!

    I'll try this also. Thanks!
     
    geekos, Apr 30, 2010 IP