Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2007
    Location
    London
    Posts
    1,577
    Tokens
    36

    Latest Awards:

    Default PHP Explode/Split...?

    Hello,

    I need a little help splitting up/exploding a variable in PHP.

    Say this is my variable:

    2;C;/Diamond/0/DiamondM2/thedeath-v2.321//;C;/Diamond/16/DiamondM2/thedeath-v2.321//;

    I can do:

    PHP Code:
    $u split(";",$mylongvariable);
            
    $u split("/",$u[4]);
            
    $user $u[2]; 
    And $user will = 16, the part of the string that I'm after.

    However for this variable:

    2;Sting/99/0/GOOD;Sting/0/6/GOOD;

    I need to get the 6 (nearish the end). How would I do that?

    Thanks and +rep to correct answer.
    Kind Regards,

    Guy
    __________________

    Since 2007. Unbelievable Uptime. Web hosting, resellers, master resellers, linux VPS, windows VPS, shoutcasts, at the lowest prices on the net.
    Tech-Hosts.co.uk.


  2. #2
    Join Date
    Oct 2008
    Posts
    43
    Tokens
    0

    Default

    Quote Originally Posted by iUnknown View Post
    Hello,

    I need a little help splitting up/exploding a variable in PHP.

    Say this is my variable:

    2;C;/Diamond/0/DiamondM2/thedeath-v2.321//;C;/Diamond/16/DiamondM2/thedeath-v2.321//;

    I can do:

    PHP Code:
    $u split(";",$mylongvariable);
            
    $u split("/",$u[4]);
            
    $user $u[2]; 
    And $user will = 16, the part of the string that I'm after.

    However for this variable:

    2;Sting/99/0/GOOD;Sting/0/6/GOOD;

    I need to get the 6 (nearish the end). How would I do that?

    Thanks and +rep to correct answer.
    Hey,

    I'm having a little trouble figuring out why on earth you want all this?
    But since you asked for the second example, I think, off my head this should work (as long as I counted my /'s correctly)


    PHP Code:
    $u split("/","2;Sting/99/0/GOOD;Sting/0/6/GOOD;");
            
    $out$u[5]; 

    CS-Dude
    Last edited by CS-dude; 22-10-2008 at 09:24 PM.

  3. #3
    Join Date
    Nov 2007
    Location
    London
    Posts
    1,577
    Tokens
    36

    Latest Awards:

    Default

    That might of worked, but I managed to do it myself with this:

    PHP Code:
    $u split(";",$mylongvariable);
            
    $u split("/",$u[2]);
    $user $u[2]; 
    I just had to think about it a bit. It helps me to lay it out in a post sometimes

    Thanks for your efforts though, +rep.

    Thread closed.
    Kind Regards,

    Guy
    __________________

    Since 2007. Unbelievable Uptime. Web hosting, resellers, master resellers, linux VPS, windows VPS, shoutcasts, at the lowest prices on the net.
    Tech-Hosts.co.uk.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •