php.net |  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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jj at danskscanning dot dk
New email:
PHP Version: OS:

 

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

Test script:
---------------
<?php

$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:
----------------
foo/bar[]=1&foo/bar[]=2&bar=foo

Actual result:
--------------
foo/bar[0]=1&foo/bar[1]=2&bar=foo

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-07-17 23:26 UTC] k.schroeder@php.net
Automatic comment from SVN on behalf of k.schroeder
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=301354
Log: Test for #52359
 [2010-07-19 11:54 UTC] aharvey@php.net
-Status: Open +Status: Bogus
 [2010-07-19 11:54 UTC] aharvey@php.net
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 Dec 22 11:01:30 2024 UTC