1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

need help with php preg_replace

Discussion in 'Web Design' started by madbutcher, May 13, 2013.

  1. madbutcher

    madbutcher Newbie

    Joined:
    Jul 17, 2008
    Messages:
    15
    Likes Received:
    2
    Hi guys, could someone help me pls, i am getting this error :
    Warning: preg_replace() [function.preg-replace]: No ending delimiter '&' found in /home/elutod0/public_html/xxxx.com/xmlparser.php on line 771
    in this code:
    Code:
    $nq = preg_replace("&page=[a-zA-Z0-9]*", "", $_SERVER['QUERY_STRING']);
     
    Last edited: May 13, 2013
  2. fatboy

    fatboy Elite Member

    Joined:
    Aug 13, 2008
    Messages:
    1,618
    Likes Received:
    3,227
    Occupation:
    Retired
    Location:
    Old Peoples Home
  3. Xp3r7

    Xp3r7 Regular Member

    Joined:
    Sep 9, 2011
    Messages:
    286
    Likes Received:
    386
    Occupation:
    Freelancer
    Location:
    In the middle of nowhere
    Try with this:
    Code:
    $nq = preg_replace("/&page=[a-zA-Z0-9]*/", "", $_SERVER['QUERY_STRING']);
     
    • Thanks Thanks x 1
  4. Gogol

    Gogol Elite Member

    Joined:
    Sep 10, 2010
    Messages:
    3,062
    Likes Received:
    2,872
    Gender:
    Male
    Code:
    $nq = preg_replace("#&page=[a-zA-Z0-9]*#", "", $_SERVER['QUERY_STRING']);
    Code:
    $nq = preg_replace("#\&page=[a-zA-Z0-9]*#", "", $_SERVER['QUERY_STRING']);
    (not sure if you need to escape the amp.. try both out)
     
    • Thanks Thanks x 1
  5. madbutcher

    madbutcher Newbie

    Joined:
    Jul 17, 2008
    Messages:
    15
    Likes Received:
    2
    Thank you very much guys!
    Xp3r7, your thing worked!