Skip to content
Snippets Groups Projects
Commit 4bec7c26 authored by Olav Morken's avatar Olav Morken
Browse files

Utilities: Added parseQueryString function.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@738 44740490-163a-0410-bde0-09ae8108e29a
parent ff69236e
No related branches found
No related tags found
No related merge requests found
......@@ -1095,6 +1095,37 @@ class SimpleSAML_Utilities {
return $baseHost . $dir . $tail;
}
/**
* Parse a query string into an array.
*
* This function parses a query string into an array, similar to the way the builtin
* 'parse_str' works, except it doesn't handle arrays, and it doesn't do "magic quotes".
*
* Query parameters without values will be set to an empty string.
*
* @param $query_string The query string which should be parsed.
* @return The query string as an associative array.
*/
public function parseQueryString($query_string) {
assert('is_string($query_string)');
$res = array();
foreach(split('&', $query_string) as $param) {
$param = split('=', $param);
$name = urldecode($param[0]);
if(count($param) === 1) {
$value = '';
} else {
$value = urldecode($param[1]);
}
$res[$name] = $value;
}
return $res;
}
}
?>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment