Req #80536 [NEW]: http_build_query dense numerically indexed arrays without brackets flag?
From: divinity76 at gmail dot com
Operating system:
PHP version: Next Minor Version
Package: URL related
Bug Type: Feature/Change Request
Bug description:http_build_query dense numerically indexed arrays without brackets flag?
Description:
------------
there are some apis which doesn't support http_build_query()'s array
method of foo[0]=a&foo[1]=b&foo[2]=c, instead specifying arrays like
foo=a&foo=b&foo=c ,
one such api is Google's Closure Compiler Rest API,
https://developers.google.com/closure/compiler/docs/gettingstarted_api
i recently had to generate a POST request to that api through PHP, i
ended up doing
```
"output_info=compiled_code&output_info=warnings&output_info=errors&output_info=statistics&"
. http_build_query(array(
'output_format' => 'json',
'compilation_level' => $compile_level,
'warning_level' => 'verbose',
'js_code' => $js_to_minify
))
```
i had to hack the output_info array data in there, instead of doing it
the "proper way" of
```
http_build_query(array(
'output_format' => 'json',
'compilation_level' => $compile_level,
'warning_level' => 'verbose',
'js_code' => $js_to_minify,
'output_info' => array('compiled_code', 'warnings',
'errors',
'statistics')
))
```
it would be nice if http_build_query() could get a flag to treat
numerically indexed densely populated arrays (eg what you get from
array_values() or array("a","b","c") ) without brackets..
(there's
probably a better name for it, idk what)
not sure what the flag name should be though,
PHP_QUERY_DENSE_NUMERICALLY_INDEXED_ARRAYS_WITHOUT_BRACKETS kinda feels
too long
Test script:
---------------
<?php
echo http_build_query(
["foo"=>["a","b","c"]],
null,
'&',
PHP_QUERY_DENSE_NUMERICALLY_INDEXED_ARRAYS_WITHOUT_BRACKETS
);
Expected result:
----------------
foo=a&foo=b&foo=c
--
Edit bug report at https://bugs.php.net/bug.php?id=80536&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=80536&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=80536&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=80536&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=80536&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=80536&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=80536&r=support
Expected behavior: https://bugs.php.net/fix.php?id=80536&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=80536&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=80536&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=80536&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=80536&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=80536&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=80536&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=80536&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=80536&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=80536&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=80536&r=mysqlcfg
Thread (3 messages)
- divinity76 at gmail dot com