Bug #67008 [NEW]: http_build_query() doesn't properly handle array without keys

From: Date: Thu, 03 Apr 2014 03:08:13 +0000
Subject: Bug #67008 [NEW]: http_build_query() doesn't properly handle array without keys
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-185053@lists.php.net to get a copy of this message
From: chuanm at gmail dot com Operating system: any PHP version: 5.4.26 Package: HTTP related Bug Type: Bug Bug description:http_build_query() doesn't properly handle array without keys Description: ------------ 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: --------------- <?php 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: ---------------- user_ids%5B%5D=1313346&user_ids%5B%5D=1313342&user_ids%5B%5D=1313345 Actual result: -------------- user_ids%5B0%5D=1313346&user_ids%5B1%5D=1313342&user_ids%5B2%5D=1313345 -- Edit bug report at https://bugs.php.net/bug.php?id=67008&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=67008&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=67008&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=67008&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=67008&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=67008&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=67008&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=67008&r=needscript Try newer version: https://bugs.php.net/fix.php?id=67008&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=67008&r=support Expected behavior: https://bugs.php.net/fix.php?id=67008&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=67008&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=67008&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=67008&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=67008&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=67008&r=dst IIS Stability: https://bugs.php.net/fix.php?id=67008&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=67008&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=67008&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=67008&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=67008&r=mysqlcfg

« previous php.bugs (#185053) next »