title: PHP—array_merge_recursive() - no Array for same keys
body: <pre><code>$php -a
  php &gt; $data1 = ['tag' =&gt; 'div', 'classes' =&gt; [1,2,3]];
  php &gt; $data2 = ['tag' =&gt; 'section', 'classes' =&gt; [2,3,4,5,6]];
  php &gt; $result = array_merge_recursive($data1, $data2);
  php &gt; print_r($result);
  Array
  (
      [tag] =&gt; Array
          (
              [0] =&gt; div
              [1] =&gt; section
          )
  
      [classes] =&gt; Array
          (
              [0] =&gt; 1
              [1] =&gt; 2
              [2] =&gt; 3
              [3] =&gt; 2
              [4] =&gt; 3
              [5] =&gt; 4
              [6] =&gt; 5
              [7] =&gt; 6
          )
  
   )
  </code></pre>
  
  <p>So as describes in the <a href="http://php.net/manual/en/function.array-merge-recursive.php" rel="nofollow noreferrer">Docs</a>:</p>
  
  <blockquote>
    <p>If the input arrays have the same string keys, then the values for these keys are merged together into an array[…]</p>
  </blockquote>
  
  <p>Is there a existing function within PHP that basically does the same, but without merging the same keys into an array, so that the values are overridden and the key kept?</p>
  
  <p>In this case I would like to have that result:</p>
  
  <pre><code>Array
  (
      [tag] =&gt; section
  
      [classes] =&gt; Array
          (
              [0] =&gt; 1
              [1] =&gt; 2
              [2] =&gt; 3
              [5] =&gt; 4
              [6] =&gt; 5
              [7] =&gt; 6
          )
  
   )
  </code></pre>
  
  <p>In regards to the comment of @JustOnUnderMillions:</p>
  
  <p>Yes I wonder, that is not what I would expect of such a function, I would expect a result as I am looking for.</p>