title: How can I convert a string with square brackets into an array?
body: <p>I got this from the name attribute of a field</p>
  
  <pre><code>name="field[a][2][b][0][c][1][field_name]"
  </code></pre>
  
  <p>after serializing the form, I got this:</p>
  
  <pre><code>array('field[a][2][b][0][c][1][field_name]'=&gt;'value')
  </code></pre>
  
  <p>and I need to convert that into the following array:</p>
  
  <pre><code>$field = array (
           'a' =&gt; array (
                  [2] =&gt; array (
                         'b' =&gt; array (
                                [0] =&gt; array (
                                       'c' =&gt; array (
                                              [1] =&gt; array (
                                                   'field_name'=&gt;'value'
                                              )
                                        )
                                 )
                          )
                    )
             )
      );
  </code></pre>
  
  <p>do I need some sort of foreach function or php can recognize this string as array?</p>