I shouldn't've posted the original version, as it only worked with the most basic of query strings.
This function will parse an html-safe query-like url string for variables and php-like ordered and associative arrays. It places them into the global scope as parse_str does and adds minimal slashes for database insertions without the triple-slash problems that magic quotes can produce (the reason I had to write it in the first place). If you don't need the slashes, they're easy enough to remove.
<?php
function parse_query($str) {
$pairs = explode('&', $str);
foreach($pairs as $pair) {
list($name, $value) = explode('=', $pair, 2);
list($name, $index) = split('[][]', urldecode($name));
if(isset($index)) {
global $$name;
if(!isset($$name)) $$name = array();
if($index != "") {
${$name}[$index] = addslashes(urldecode($value));
} else {
array_push($$name, addslashes(urldecode($value)));
}
} else {
global $$name;
$$name = addslashes(urldecode($value));
}
}
}
?>