| 
        php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
  [2013-02-28 16:09 UTC] 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
)
Patchesbug64325.patch (last revision 2013-03-01 03:29 UTC by laruence@php.net)Pull RequestsHistoryAllCommentsChangesGit/SVN commits             
             | 
    |||||||||||||||||||||||||||
            
                 
                Copyright © 2001-2025 The PHP GroupAll rights reserved.  | 
        Last updated: Tue Nov 04 02:00:01 2025 UTC | 
"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'] ] ); ?