<?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 => 'de',
  ),
  'this' => 
  array (
    0 => 'function.array-replace-recursive.php',
    1 => 'array_replace_recursive',
    2 => 'Ersetzt rekursiv Elemente des ersten Arrays durch Elemente der &uuml;bergebenen Arrays',
  ),
  'up' => 
  array (
    0 => 'ref.array.php',
    1 => 'Array Funktionen',
  ),
  'prev' => 
  array (
    0 => 'function.array-replace.php',
    1 => 'array_replace',
  ),
  'next' => 
  array (
    0 => 'function.array-reverse.php',
    1 => 'array_reverse',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'de',
    'path' => 'reference/array/functions/array-replace-recursive.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.array-replace-recursive" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">array_replace_recursive</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.3.0, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">array_replace_recursive</span> &mdash; <span class="dc-title">Ersetzt rekursiv Elemente des ersten Arrays durch Elemente der übergebenen Arrays</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.array-replace-recursive-description">
  <h3 class="title">Beschreibung</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>array_replace_recursive</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.array.php" class="type array">array</a></span> <code class="parameter">$array</code></span>, <span class="methodparam"><span class="type"><a href="language.types.array.php" class="type array">array</a></span> <code class="parameter">...$replacements</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_replace_recursive()</strong></span> ersetzt die Werte von
   <code class="parameter">array</code> durch die gleichen Werte aus allen folgenden
   Arrays. Wenn ein Schlüssel aus dem ersten Array im zweiten Array vorhanden
   ist, wird sein Wert durch den Wert aus dem zweiten Array ersetzt. Wenn der
   Schlüssel im zweiten Array vorhanden ist, aber nicht im ersten, wird er im
   ersten Array erstellt. Wenn ein Schlüssel nur im ersten Array vorhanden
   ist, wird er unverändert belassen. Wenn mehrere Arrays zum Ersetzen
   übergeben werden, werden sie der Reihe nach verarbeitet, wobei das spätere
   Array die vorherigen Werte überschreibt.
  </p>
  <p class="para">
   Die Funktion <span class="function"><strong>array_replace_recursive()</strong></span> ist rekursiv: sie
   rekursiert in Arrays und wendet den gleichen Prozess auf den inneren Wert an.
  </p>
  <p class="para">
   Wenn der Wert im ersten Array ein Skalar ist, wird er durch den Wert im
   zweiten Array ersetzt, egal ob es sich um einen Skalar oder ein Array
   handelt. Wenn sowohl der Wert im ersten Array als auch der Wert im zweiten
   Array ein Array ist, ersetzt <span class="function"><strong>array_replace_recursive()</strong></span>
   den jeweiligen Wert rekursiv.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.array-replace-recursive-parameters">
  <h3 class="title">Parameter-Liste</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">array</code></dt>
     <dd>
      <p class="para">
       Das Array, dessen Elemente ersetzt werden.
      </p>
     </dd>
    
    
     <dt><code class="parameter">replacements</code></dt>
     <dd>
      <p class="para">
       Arrays, aus denen Elemente ausgelesen werden sollen.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.array-replace-recursive-returnvalues">
  <h3 class="title">Rückgabewerte</h3>
  <p class="para">
   Gibt ein <span class="type"><a href="language.types.array.php" class="type Array">Array</a></span> zurück.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.array-replace-recursive-examples">
  <h3 class="title">Beispiele</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Beispiel #1 <span class="function"><strong>array_replace_recursive()</strong></span>-Beispiel</strong></p>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$base </span><span style="color: #007700">= array(</span><span style="color: #DD0000">'citrus' </span><span style="color: #007700">=&gt; array(</span><span style="color: #DD0000">"orange"</span><span style="color: #007700">), </span><span style="color: #DD0000">'berries' </span><span style="color: #007700">=&gt; array(</span><span style="color: #DD0000">"blackberry"</span><span style="color: #007700">, </span><span style="color: #DD0000">"raspberry"</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">$replacements </span><span style="color: #007700">= array(</span><span style="color: #DD0000">'citrus' </span><span style="color: #007700">=&gt; array(</span><span style="color: #DD0000">'pineapple'</span><span style="color: #007700">), </span><span style="color: #DD0000">'berries' </span><span style="color: #007700">=&gt; array(</span><span style="color: #DD0000">'blueberry'</span><span style="color: #007700">));<br /><br /></span><span style="color: #0000BB">$basket </span><span style="color: #007700">= </span><span style="color: #0000BB">array_replace_recursive</span><span style="color: #007700">(</span><span style="color: #0000BB">$base</span><span style="color: #007700">, </span><span style="color: #0000BB">$replacements</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$basket</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$basket </span><span style="color: #007700">= </span><span style="color: #0000BB">array_replace</span><span style="color: #007700">(</span><span style="color: #0000BB">$base</span><span style="color: #007700">, </span><span style="color: #0000BB">$replacements</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$basket</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>Das oben gezeigte Beispiel erzeugt folgende Ausgabe:</p></div>
    <div class="example-contents screen">
<div class="annotation-interactive examplescode"><pre class="examplescode">Array
(
    [citrus] =&gt; Array
        (
            [0] =&gt; pineapple
        )

    [berries] =&gt; Array
        (
            [0] =&gt; blueberry
            [1] =&gt; raspberry
        )

)
Array
(
    [citrus] =&gt; Array
        (
            [0] =&gt; pineapple
        )

    [berries] =&gt; Array
        (
            [0] =&gt; blueberry
        )

)</pre>
</div>
    </div>
   </div>
   <div class="example" id="example-2">
    <p><strong>Beispiel #2 <span class="function"><strong>array_replace_recursive()</strong></span> und rekursives Verhalten</strong></p>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$base </span><span style="color: #007700">= array(</span><span style="color: #DD0000">'citrus' </span><span style="color: #007700">=&gt; array(</span><span style="color: #DD0000">"orange"</span><span style="color: #007700">) , </span><span style="color: #DD0000">'berries' </span><span style="color: #007700">=&gt; array(</span><span style="color: #DD0000">"blackberry"</span><span style="color: #007700">, </span><span style="color: #DD0000">"raspberry"</span><span style="color: #007700">), </span><span style="color: #DD0000">'others' </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">'banana' </span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$replacements </span><span style="color: #007700">= array(</span><span style="color: #DD0000">'citrus' </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">'pineapple'</span><span style="color: #007700">, </span><span style="color: #DD0000">'berries' </span><span style="color: #007700">=&gt; array(</span><span style="color: #DD0000">'blueberry'</span><span style="color: #007700">), </span><span style="color: #DD0000">'others' </span><span style="color: #007700">=&gt; array(</span><span style="color: #DD0000">'litchis'</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">$replacements2 </span><span style="color: #007700">= array(</span><span style="color: #DD0000">'citrus' </span><span style="color: #007700">=&gt; array(</span><span style="color: #DD0000">'pineapple'</span><span style="color: #007700">), </span><span style="color: #DD0000">'berries' </span><span style="color: #007700">=&gt; array(</span><span style="color: #DD0000">'blueberry'</span><span style="color: #007700">), </span><span style="color: #DD0000">'others' </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">'litchis'</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$basket </span><span style="color: #007700">= </span><span style="color: #0000BB">array_replace_recursive</span><span style="color: #007700">(</span><span style="color: #0000BB">$base</span><span style="color: #007700">, </span><span style="color: #0000BB">$replacements</span><span style="color: #007700">, </span><span style="color: #0000BB">$replacements2</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$basket</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>Das oben gezeigte Beispiel erzeugt folgende Ausgabe:</p></div>
    <div class="example-contents screen">
<div class="annotation-interactive examplescode"><pre class="examplescode">Array
(
    [citrus] =&gt; Array
        (
            [0] =&gt; pineapple
        )

    [berries] =&gt; Array
        (
            [0] =&gt; blueberry
            [1] =&gt; raspberry
        )

    [others] =&gt; litchis
)</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.array-replace-recursive-seealso">
  <h3 class="title">Siehe auch</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.array-replace.php" class="function" rel="rdfs-seeAlso">array_replace()</a> - Ersetzt Elemente von &uuml;bergebenen Arrays im ersten Array</span></li>
    <li><span class="function"><a href="function.array-merge-recursive.php" class="function" rel="rdfs-seeAlso">array_merge_recursive()</a> - F&uuml;hrt ein oder mehrere Arrays rekursiv zusammen</span></li>
   </ul>
  </p>
 </div>


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