<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.array.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'en',
  ),
  'this' => 
  array (
    0 => 'function.array-merge-recursive.php',
    1 => 'array_merge_recursive',
    2 => 'Merge one or more arrays recursively',
  ),
  'up' => 
  array (
    0 => 'ref.array.php',
    1 => 'Array Functions',
  ),
  'prev' => 
  array (
    0 => 'function.array-merge.php',
    1 => 'array_merge',
  ),
  'next' => 
  array (
    0 => 'function.array-multisort.php',
    1 => 'array_multisort',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/array/functions/array-merge-recursive.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.array-merge-recursive" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">array_merge_recursive</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.0.1, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">array_merge_recursive</span> &mdash; <span class="dc-title">Merge one or more arrays recursively</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.array-merge-recursive-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>array_merge_recursive</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.array.php" class="type array">array</a></span> <code class="parameter">...$arrays</code></span>): <span class="type"><a href="language.types.array.php" class="type array">array</a></span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>array_merge_recursive()</strong></span> merges the elements of
   one or more arrays together so that the values of one are appended
   to the end of the previous one.  It returns the resulting array.
  </p>
  <p class="para">
   If the input arrays have the same string keys, then the values for
   these keys are merged together into an array, and this is done
   recursively, so that if one of the values is an array itself, the
   function will merge it with a corresponding entry in another array
   too. If, however, the arrays have the same numeric key, the later
   value will not overwrite the original value, but will be appended.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.array-merge-recursive-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">arrays</code></dt>
     <dd>
      <p class="para">
       Variable list of arrays to recursively merge.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.array-merge-recursive-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   An array of values resulted from merging the arguments together.
   If called without any arguments, returns an empty <span class="type"><a href="language.types.array.php" class="type array">array</a></span>.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.array-merge-recursive-changelog">
  <h3 class="title">Changelog</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Version</th>
       <th>Description</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>7.4.0</td>
       <td>
        This function can now be called without any parameter.
        Formerly, at least one parameter has been required.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.array-merge-recursive-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Example #1 <span class="function"><strong>array_merge_recursive()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$ar1 </span><span style="color: #007700">= array(</span><span style="color: #DD0000">"color" </span><span style="color: #007700">=&gt; array(</span><span style="color: #DD0000">"favorite" </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"red"</span><span style="color: #007700">), </span><span style="color: #0000BB">5</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$ar2 </span><span style="color: #007700">= array(</span><span style="color: #0000BB">10</span><span style="color: #007700">, </span><span style="color: #DD0000">"color" </span><span style="color: #007700">=&gt; array(</span><span style="color: #DD0000">"favorite" </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"green"</span><span style="color: #007700">, </span><span style="color: #DD0000">"blue"</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">$result </span><span style="color: #007700">= </span><span style="color: #0000BB">array_merge_recursive</span><span style="color: #007700">(</span><span style="color: #0000BB">$ar1</span><span style="color: #007700">, </span><span style="color: #0000BB">$ar2</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$result</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>The above example will output:</p></div>
    <div class="example-contents screen">
<div class="annotation-interactive examplescode"><pre class="examplescode">Array
(
    [color] =&gt; Array
        (
            [favorite] =&gt; Array
                (
                    [0] =&gt; red
                    [1] =&gt; green
                )

            [0] =&gt; blue
        )

    [0] =&gt; 5
    [1] =&gt; 10
)</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.array-merge-recursive-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.array-merge.php" class="function" rel="rdfs-seeAlso">array_merge()</a> - Merge one or more arrays</span></li>
    <li><span class="function"><a href="function.array-replace-recursive.php" class="function" rel="rdfs-seeAlso">array_replace_recursive()</a> - Replaces elements from passed arrays into the first array recursively</span></li>
   </ul>
  </p>
 </div>

</div><?php manual_footer($setup); ?>