split word by space char

Discussion in 'PHP' started by srdva59, May 2, 2009.

  1. #1
    hi,
    i have a list of words like this:

    Mon Apr 27 12
    Tue Apr 28 15:43:24 20
    Tue Apr
    Tue Apr 28 16:1
    Tue Apr 28 09:38:31
    Wed Apr 29 10
    Wed Apr 29 2
    Mon Apr 27 0
    Wed Apr 29 21:1
    Fri May
    Mon Apr
    Wed Apr

    and i want remove the wed apr and all data after the e-mail and
    keep only the e-mails.
    how can i do that?
    thanks a lot for your help
    :)
     
    srdva59, May 2, 2009 IP
  2. Kaizoku

    Kaizoku Well-Known Member

    Messages:
    1,261
    Likes Received:
    20
    Best Answers:
    1
    Trophy Points:
    105
    #2
    You can either use regex (regular expression) or just explode it.

    $str = "theisml35@berkleyintl.com Mon Apr 27 12";
    list($email, $date) = explode(' ', $str);
     
    Kaizoku, May 2, 2009 IP
  3. JDevereux

    JDevereux Peon

    Messages:
    50
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    $str = "theisml35@berkleyintl.com Mon Apr 27 12";
    $space = strpos($str, " ");
    $new_str = substr($str, 0, $space);
    PHP:
     
    JDevereux, May 2, 2009 IP