This is doing my **** in.
Does anybody knows a clean solution for removing duplicated string + values from a querystring?
ex. page.php?1=1&2=2&1=3 to page.php?2=2&1=3
querystring remove duplicate
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
parse_str() combined with something else, maybe?
PHP will automatically handle the smashing down of the information if you're worried about that.
PHP will automatically handle the smashing down of the information if you're worried about that.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
all i needed was a clear head. I came up with this:
if you know a better solution let me know.
Code: Select all
$a = explode("&", $_SERVER['QUERY_STRING']);
$query = array_unique($a);
foreach($query as $q_name){
$query_s .= $q_name."&";
}
$query_s = rtrim($query_s,"&");//remove last trailing &- stereofrog
- Forum Contributor
- Posts: 386
- Joined: Mon Dec 04, 2006 6:10 am