php array merge
<p>I have 2 arrays:</p>

<p>1 array:</p>

<pre><code>array(
  'user' =&gt; 
    array
      'info' =&gt; 
        array
          'firstname' =&gt; string 'name'
          'lastname' =&gt; string 'lname'
  'password' =&gt; string 'pass123'
  'select' =&gt; 
    array
      'a' =&gt; 
        array
          'b' =&gt; 
            array
              0 =&gt; string '1'
              1 =&gt; string '2'
              2 =&gt; string '3'
);
</code></pre>

<p>2 array :</p>

<pre><code>array(
  'user[info][firstname]' =&gt; ''
  'user[info][lastname]' =&gt; ''
  'password' =&gt; ''
  'select[a][b][]' =&gt; ''
);
</code></pre>

<p>And I want somehow to merge them like this:</p>

<pre><code>array(
  'user[info][firstname]' =&gt; 'name'
  'user[info][lastname]' =&gt; 'lname'
  'password' =&gt; 'pass123'
  'select[a][b][]' =&gt; 
      array(
          0 =&gt; string '1'
          1 =&gt; string '2'
          2 =&gt; string '3')
);
</code></pre>

<p>This is only a simple example (array keys can change. Can be like this: user[info][firstname][123][]). I would be grateful for some ideas </p>

<p><strong>EDIT:</strong></p>

<p>Ok, i will try to Explain why i need this.</p>

<p>I am using script that automatically generates HTML forms from XML file like this:</p>

<pre><code>&lt;form method="post"&gt;
&lt;input type="text" name="user[info][firstname]"&gt;
&lt;select name="select[a][b][]" multiple="multiple"&gt;
    &lt;option value="1"&gt;1&lt;/option&gt;
    &lt;option value="2"&gt;2&lt;/option&gt;
    &lt;option value="3"&gt;3&lt;/option&gt;
&lt;/select&gt;
&lt;/form&gt;
</code></pre>

<p>So array 1 is $_POST. After submit i want to refill form fields, but i can do this only by form element name (user[info][firstname]). Thats why I need to generate an array 3</p>

<p>I need ideas how this could be implemented. Thank you</p>
