Quick Question!!

Discussion in 'PHP' started by chuckd1356, Mar 25, 2008.

  1. #1
    So here's the deal.
    I have a string that looks like this:
    
    $str = 'me:foo bar foo bar foo bar foo bar <*fancy*delimiter*>
              you:bar foo bar foo bar foo <*fancy*delimiter*> 
              me:foo bar foo bar foo bar foo bar <*fancy*delimiter*>
              you:bar foo bar foo bar foo <*fancy*delimiter*>
              me:foo bar foo bar foo bar foo bar <*fancy*delimiter*>
              you:bar foo bar foo bar foo <*fancy*delimiter*> ';
    
    PHP:
    And all I need to do, is pull out the last string after the delimiter... the you:bar foo bar foo bar goo...
    Can I use a negative limit on explode()?
     
    chuckd1356, Mar 25, 2008 IP
  2. Marc Fraser

    Marc Fraser Peon

    Messages:
    283
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Sure you can use negative values (the last time I checked!!)
     
    Marc Fraser, Mar 25, 2008 IP
  3. chuckd1356

    chuckd1356 Active Member

    Messages:
    770
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    70
    #3
    Yeah, no kidding. The real issue is, that wont work. Because when you use a negative limit, all you do is drop the last piece. So I need to drop everything else except the last piece.

    Maybe I could explode it all, go to the last result of the array, and then use substr()?
     
    chuckd1356, Mar 25, 2008 IP
  4. chuckd1356

    chuckd1356 Active Member

    Messages:
    770
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    70
    #4
    Nevermind. I can use array_pop to get it, and then substr to get what I need out of it.
     
    chuckd1356, Mar 25, 2008 IP
  5. Gordaen

    Gordaen Peon

    Messages:
    277
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Can you just trim the string and do a regex search for "delimiter(.*)delimiter$"?
     
    Gordaen, Mar 26, 2008 IP