Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- preg_replace("%(?<=[?&])$param=.+(&|$)%", '', $url);
- $string = 'https://www.google.com/search?q=Metallica+Turn+The+Page&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a&channel=sb';
- $string = preg_replace('~?.*~', '', $string);
- print $string;
- https://www.google.com/search
- // REPLACE ALL OF THE PARAMS WITH DUMMY-PARAM
- $string = 'https://www.google.com/search?q=Metallica+Turn+The+Page&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a&channel=sb';
- $string = preg_replace('~[?&]K([A-Z0-9+%]+)=.+?(?=&|$)~i', '$1=DUMMY-PARAM', $string);
- print "nn".$string;
- // REPLACE ALL OF THE KEYS WITH DUMMY-KEY
- $string = 'https://www.google.com/search?q=Metallica+Turn+The+Page&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a&channel=sb';
- $string = preg_replace('~[?&]K[A-Z0-9+%]+=(.+?)(?=&|$)~i', 'DUMMY-KEY=$1', $string);
- print "nn".$string;
- // PULL OUT ALL KEYS/VALUES
- $string = 'https://www.google.com/search?q=Metallica+Turn+The+Page&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a&channel=sb';
- $string = preg_replace('~[?&]K([A-Z0-9+%]+)=(.+?)(?=&|$)~i', "n$1: $2", $string);
- print "nn".$string;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement