title: PHP : multidimensional array merge recursive
body: <p>I need to merge those two arrays:</p>
  
  <pre><code>$ar1 = array("color" =&gt; array("red", "green"), "aa");
  $ar2 = array("color" =&gt; array( "green", "blue"), "bb");
  $result = array_merge_recursive($ar1, $ar2);
  </code></pre>
  
  <p>Expected output:</p>
  
  <pre><code>[
      'color' =&gt; [
          (int) 0 =&gt; 'red',
          (int) 1 =&gt; 'green',
          (int) 3 =&gt; 'blue'
      ],
      (int) 0 =&gt; 'aa',
      (int) 1 =&gt; 'bb'
  ]
  </code></pre>
  
  <p>But it outputs:</p>
  
  <pre><code>[
      'color' =&gt; [
          (int) 0 =&gt; 'red',
          (int) 1 =&gt; 'green',
          (int) 2 =&gt; 'green', (!)
          (int) 3 =&gt; 'blue'
      ],
      (int) 0 =&gt; 'aa',
      (int) 1 =&gt; 'bb'
  ]
  </code></pre>
  
  <p>I'm looking for the simplest way to do this, my array inputs won't be deeper than those examples.</p>