#21 Allow submit POST associative array

open
nobody
None
5
2011-02-04
2011-02-04
Anonymous
No

Fixed submit POST associative array like:
Array
(
[a] => 64
[b] => 16
[login] => Array
(
[password] => password
[name] => login
)

)

Will send correct POST string for 'application/x-www-form-urlencoded' form.

Discussion


  • Anonymous
    2011-02-04

     
    Last edit: Anonymous 2014-01-02
    Attachments
  • Ruben Barkow
    Ruben Barkow
    2012-07-20

    there are still 2 bugs:
    1.
    if you have a multidimensional array, this can be solved fast by json_encode()
    but better would be a recursive function for it.
    2.
    if you use special chars in your array key like ä, ö, ï, ü, ...
    urlencode is missing there too

    better solution is
    if(is_array($cur_val)) $cur_val=json_encode($cur_val);
    // $postdata .= urlencode($key) ."[$cur_key]=". urlencode($cur_val)."&";
    echo $postdata .= urlencode($key) ."%5B".urlencode($cur_key)."%5D=". urlencode($cur_val)."&";