how to remove variable and its value from url ?

Discussion in 'PHP' started by ramysarwat, Nov 3, 2009.

  1. #1
    how to remove a variable and its value which can be any value for example 123456 from this url

    http://www.eample.com/test.php?a=123456&b=754&c=2254
     
    ramysarwat, Nov 3, 2009 IP
  2. Colbyt

    Colbyt Notable Member

    Messages:
    3,224
    Likes Received:
    185
    Best Answers:
    0
    Trophy Points:
    210
    #2
    Are you asking how to not have it show in the URL?

    Or how to extract it from the URL to use in a script for some purpose. This is quite common.
     
    Colbyt, Nov 3, 2009 IP
  3. ramysarwat

    ramysarwat Peon

    Messages:
    164
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    i want to extraxt it from the url (remove it) and use the rest of the url
     
    ramysarwat, Nov 3, 2009 IP
  4. morgano

    morgano Active Member

    Messages:
    330
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    60
    #4
    $url_array = array();
    $url_array = parse_url($your_url);
    
    print_r($url_array);
    Code (markup):
     
    morgano, Nov 3, 2009 IP
  5. ramysarwat

    ramysarwat Peon

    Messages:
    164
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    thank you morgano but this way will devide the url into parts

    all what i want to do is remove the unwanted part which is a=123456
     
    ramysarwat, Nov 3, 2009 IP
  6. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #6
    Can you explain how you intend on using the remainder of the url. I think it will help give a more appropriate answer.

    If you need to use the url as-is without the value pair, you would want to use parse url, and then reconstruct the url without the undesired variable. This way you are certain to remove the full parameter and value.
     
    jestep, Nov 3, 2009 IP
  7. ramysarwat

    ramysarwat Peon

    Messages:
    164
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    i will try and see what happen
     
    ramysarwat, Nov 3, 2009 IP