|  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
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-2022 The PHP Group
All rights reserved.
Last updated: Tue May 17 05:05:45 2022 UTC