In PHP, I need a function to convert a querystring from an URL, say: http://example.com?key1=value1&key2=value2
into a PHP associative array : array [
If you mean as what you written then it is very simple and don't need anything else there is a predefined Superglobal variable $_GET
in PHP which itself represents all the query string as key, value pairs associative array.
Example:
// current page URI: http://localhost/test.php?key1=value1&key2=value2
echo '';
print_r($_GET);
echo '
';
Result:
Array(
[key1] = value1
[key2] = value2
)
For more information about $_GET
PHP superglobal goto: http://php.net/manual/en/reserved.variables.get.php