How to remove all this characters from my string?

Discussion in 'PHP' started by zoreli, Aug 21, 2007.

  1. #1
    Hi

    My string is something like this:

    editProduct.php?catid=86&productid=1045

    From all this, I need to remove everything except 86. Anyone can help me to do this?

    I am comming from ASP world, and I need help to do this in PHP

    Thanks in advance

    Zoreli
     
    zoreli, Aug 21, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    
    $string = 'editProduct.php?catid=86&productid=1045';
    parse_str($string, $parts);
    
    echo $parts['catid'];
    
    PHP:
    www.php.net/parse_str
     
    nico_swd, Aug 21, 2007 IP
  3. zoreli

    zoreli Member

    Messages:
    36
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #3
    Doesn't work :confused:

    I copy & paste - and it doesnt work.
     
    zoreli, Aug 21, 2007 IP
  4. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #4
    Hm
    
    $string = 'editProduct.php?catid=86&productid=1045';
    parse_str(end(explode('?', $string)), $parts);
    
    echo $parts['catid'];
    
    PHP:
     
    nico_swd, Aug 21, 2007 IP
  5. zoreli

    zoreli Member

    Messages:
    36
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #5
    Thanks Mate :)
     
    zoreli, Aug 21, 2007 IP