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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
4 + 2 = ?
Subscribe to this entry?

 
 [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

Add a Patch

Pull Requests

Add a Pull Request

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: Thu Mar 28 20:01:28 2024 UTC