Edit report at https://bugs.php.net/bug.php?id=64325&edit=1

 ID:                 64325
 Comment by:         re...@php.net
 Reported by:        php at sygmoral dot com
 Summary:            Issue in automatic $_POST array handling
 Status:             Open
 Type:               Bug
 Package:            Arrays related
 Operating System:   Debian
 PHP Version:        5.4.12
 Block user comment: N
 Private report:     N

 New Comment:

"post_data = {'save[line[]]':'A line with text'}“


do you mean post_data = {'save[line][]':'A line with text'} ?
                                    ^^
is this you intention? 
array(
   'save' => 
        ['line' => 
             ['A line with text', 'maybe more lines']
        ]
); ?


Previous Comments:
------------------------------------------------------------------------
[2013-02-28 16:09:49] php at sygmoral dot com

Description:
------------
Php automatically puts POSTed name-value pairs with names ending in [] into 
arrays. Very handy feature! However, I notice issues when more of those square 
brackets are encountered. 

If I send a name like `save[line[]]`, then `save` will be an array and the 
first key in it will be `line[`, instead of `line[]`. It's not that I expect a 
second level of arrays - just that it doesn't strangely remove that last 
bracket. 

So suppose we have the tiny php script below, and I send this with e.g. jquery:
post_data = {'save[line[]]':'A line with text'}

Effectively, the raw POST data being sent is:
save%5Bline%5B%5D%5D=A+line+with+text

Test script:
---------------
print_r(
   $_POST['save']
);

Expected result:
----------------
POST: Array
(
    [line[]] => A line with text
)

Actual result:
--------------
POST: Array
(
    [line[] => A line with text
)


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=64325&edit=1

Reply via email to