|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52359 http_build_query seem to encode array incorrectly
Submitted: 2010-07-16 11:25 UTC Modified: 2010-07-19 11:54 UTC
From: jj at danskscanning dot dk Assigned:
Status: Not a bug Package: URL related
PHP Version: Irrelevant OS: Windows XP SP3
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: jj at danskscanning dot dk
New email:
PHP Version: OS:


 [2010-07-16 11:25 UTC] jj at danskscanning dot dk
I was working in VS.php with a CodeIgniter Project (5.2) and have not made any 
changes to the standard setup.

Test script:

$a = array(); 
$a["foo/bar"] = array();
$a["foo/bar"][] = "1";
$a["foo/bar"][] = "2";
$a["bar"] = "foo";

$b = http_build_query($a, NULL, "&");
// $b
// expected : foo%2Fbar%5B%5D=1&foo%2Fbar%5B%5D=2&bar=foo
// produced : foo%2Fbar%5B0%5D=1&foo%2Fbar%5B1%5D=2&bar=foo

$c = urldecode($b);
// $c
// expected : foo/bar[]=1&foo/bar[]=2&bar=foo
// produced : foo/bar[0]=1&foo/bar[1]=2&bar=foo

echo $c;

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-07-17 23:26 UTC]
Automatic comment from SVN on behalf of k.schroeder
Log: Test for #52359
 [2010-07-19 11:54 UTC]
-Status: Open +Status: Bogus
 [2010-07-19 11:54 UTC]
http_build_query() encodes the numeric keys in the output. This is
expected (and documented) behaviour.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 26 17:01:31 2024 UTC