|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67008 http_build_query() doesn't properly handle array without keys
Submitted: 2014-04-03 03:08 UTC Modified: -
Avg. Score:3.9 ± 1.4
Reproduced:6 of 6 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (16.7%)
From: chuanm at gmail dot com Assigned:
Status: Open Package: HTTP related
PHP Version: 5.4.26 OS: any
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2014-04-03 03:08 UTC] chuanm at gmail dot com
Given an array without index, http_build_query() adds numeric index 0, 1, 2,... in its output. This is working if the web server is php, but fails to work when I use php curl functions to send the array to a rails server. Rails server treats this as a hash (with the added index in http_build_query() output).

Test script:

echo http_build_query(['user_ids' => [1313346,1313342,1313345]]);
// output:
//      user_ids%5B0%5D=1313346&user_ids%5B1%5D=1313342&user_ids%5B2%5D=1313345

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request

PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Tue Oct 04 00:05:54 2022 UTC