How to combine query strings in PHP

Posted by incrediman on Stack Overflow See other posts from Stack Overflow or by incrediman
Published on 2010-06-09T00:40:57Z Indexed on 2010/06/09 0:52 UTC
Read the original article Hit count: 206

Filed under:
|
|

Given a url, and a query string, how can I get the url resulting from the combination of the query string with the url?

I'm looking for functionality similar to .htaccess's qsa. I realize this would be fairly trivial to implement completely by hand, however are there built-in functions that deal with query strings which could either simplify or completely solve this?

Example input/result sets:

Url="http://www.example.com/index.php/page?a=1"
QS ="?b=2"
Result="http://www.example.com/index.php/page?a=1&b=2"

-

Url="page.php"
QS ="?b=2"
Result="page.php?b=2"

© Stack Overflow or respective owner

Related posts about php

Related posts about query-string