Splitting A Phrase Into Variables

Discussion in 'PHP' started by CarbonLife, Jan 26, 2010.

  1. #1
    I have a variable called open which contains an email address and a url.

    Example:
    $open = "test@domain.com http://www.bbc.co.uk";

    How do I split up $open so that the email address becomes $email, and the url becomes $url?
     
    CarbonLife, Jan 26, 2010 IP
  2. alextera

    alextera Peon

    Messages:
    20
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    If there is a space between them you can use explode.
    
    $result = explode(' ', $string);
    $email = $result[0];
    $url = $result[1];
    
    PHP:
     
    alextera, Jan 26, 2010 IP
  3. CarbonLife

    CarbonLife Guest

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanking you :)
     
    CarbonLife, Jan 26, 2010 IP