Bug #67585 [NEW]: curl_setopt POSTFIELDS doesn't handle nested arrays as it should
From: zelnaga at gmail dot com
Operating system: Windows 7
PHP version: 5.6.0RC2
Package: cURL related
Bug Type: Bug
Bug description:curl_setopt POSTFIELDS doesn't handle nested arrays as it should
Description:
------------
<?php
$data = array(
'submit' => 'submit',
'var' => array(1, 2)
);
echo http_build_query($data, '', '&');
?>
That'll output the following:
submit=submit&var%5B0%5D=1&var%5B1%5D=1
It seems like curl_setopt(..., CURLOPT_POSTFIELDS, $data) ought to
behave similarly but it doesn't.
Test script:
---------------
<?php
$data = array(
'submit' => 'submit',
'var' => array(1, 2)
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://www.domain.tld/script.php');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
echo curl_exec($ch);
Expected result:
----------------
Array
(
[submit] => submit
[var] => Array
)
Actual result:
--------------
Array
(
[submit] => submit
[var] => Array
(
[0] => 1
[1] => 2
)
)
--
Edit bug report at https://bugs.php.net/bug.php?id=67585&edit=1
--
Thread (4 messages)
- zelnaga at gmail dot com