Skip to content

Instantly share code, notes, and snippets.

@auroraeosrose
Created November 14, 2012 19:55
Show Gist options
  • Save auroraeosrose/4074364 to your computer and use it in GitHub Desktop.
Save auroraeosrose/4074364 to your computer and use it in GitHub Desktop.
http_parse_query is parse_str with non-stupid api (and fits http_build_query better as well)
/* {{{ proto array http_parse_query(string encoded_string)
parses query string into array */
PHP_FUNCTION(http_parse_query)
{
char *arg;
int arglen;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg, &arglen) == FAILURE) {
return;
}
array_init(return_value);
res = estrndup(arg, arglen);
sapi_module.treat_data(PARSE_STRING, res, return_value TSRMLS_CC);
}
/* }}} */
@auroraeosrose
Copy link
Author

Note original parse_str is here http://lxr.php.net/xref/PHP_5_4/ext/standard/string.c#4209 - almost identical but for API and removal of "import into global scope" crazies

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment