|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #80536 http_build_query dense numerically indexed arrays without brackets flag?
Submitted: 2020-12-20 16:56 UTC Modified: -
From: divinity76 at gmail dot com Assigned:
Status: Open Package: URL related
PHP Version: Next Minor Version OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: divinity76 at gmail dot com
New email:
PHP Version: OS:


 [2020-12-20 16:56 UTC] divinity76 at gmail dot com
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,

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 
    '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:
echo http_build_query(

Expected result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-12-31 16:37 UTC] antonino dot spampinato86 at gmail dot com
you can't because to recover php use the super global array $_GET and overwrite the last key. $_GET['foo'] // 1 not 0 and 1
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sun Sep 25 05:05:54 2022 UTC