<?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-pad.php',
    1 => 'array_pad',
    2 => 'F&uuml;llt ein Array bis auf die angegebene L&auml;nge mit einem Wert auf',
  ),
  'up' => 
  array (
    0 => 'ref.array.php',
    1 => 'Array Funktionen',
  ),
  'prev' => 
  array (
    0 => 'function.array-multisort.php',
    1 => 'array_multisort',
  ),
  'next' => 
  array (
    0 => 'function.array-pop.php',
    1 => 'array_pop',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'de',
    'path' => 'reference/array/functions/array-pad.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.array-pad" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">array_pad</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">array_pad</span> &mdash; <span class="dc-title">Füllt ein Array bis auf die angegebene Länge mit einem Wert auf</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.array-pad-description">
  <h3 class="title">Beschreibung</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>array_pad</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.integer.php" class="type int">int</a></span> <code class="parameter">$length</code></span>, <span class="methodparam"><span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span> <code class="parameter">$value</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_pad()</strong></span> gibt eine Kopie von
   <code class="parameter">array</code> zurück, welche auf die mit
   <code class="parameter">length</code> angegebene Größe mit dem Wert
   <code class="parameter">value</code> aufgefüllt wurde. Ist der Parameter
   <code class="parameter">length</code> positiv, wird das Array rechts erweitert, ist
   er negativ, dann erfolgt die Erweiterung links. Ist der Betrag von
   <code class="parameter">length</code> kleiner oder gleich der Länge von
   <code class="parameter">array</code>, erfolgt keine Erweiterung.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.array-pad-parameters">
  <h3 class="title">Parameter-Liste</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">array</code></dt>
     <dd>
      <p class="para">
       Das Array, das aufgefüllt werden soll.
      </p>
     </dd>
    
    
     <dt><code class="parameter">length</code></dt>
     <dd>
      <p class="para">
       Die neue Größe des Arrays.
      </p>
     </dd>
    
    
     <dt><code class="parameter">value</code></dt>
     <dd>
      <p class="para">
       Der Wert, mit dem das Array <code class="parameter">array</code> aufgefüllt
       wird, falls es kleiner als <code class="parameter">length</code> ist.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.array-pad-returnvalues">
  <h3 class="title">Rückgabewerte</h3>
  <p class="para">
   Gibt eine Kopie von <code class="parameter">array</code> zurück, welche auf die
   mit <code class="parameter">length</code> angegebene Größe mit dem Wert
   <code class="parameter">value</code> aufgefüllt wurde. Ist der Parameter
   <code class="parameter">length</code> positiv, wird das Array rechts erweitert, ist
   er negativ, dann erfolgt die Erweiterung links. Ist der Betrag von
   <code class="parameter">length</code> kleiner oder gleich der Länge von
   <code class="parameter">array</code>, erfolgt keine Erweiterung.
  </p>
 </div>


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

     </thead>

     <tbody class="tbody">
      <tr>
       <td>8.3.0</td>
       <td>
        Vor 8.3 konnten nur 1048576 Elemente auf einmal hinzugefügt werden,
        nun ist dies nur noch durch die maximale Größe eines Arrays begrenzt.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.array-pad-examples">
  <h3 class="title">Beispiele</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Beispiel #1 <span class="function"><strong>array_pad()</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 />$eingabe </span><span style="color: #007700">= array(</span><span style="color: #0000BB">12</span><span style="color: #007700">, </span><span style="color: #0000BB">10</span><span style="color: #007700">, </span><span style="color: #0000BB">9</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$ergebnis </span><span style="color: #007700">= </span><span style="color: #0000BB">array_pad</span><span style="color: #007700">(</span><span style="color: #0000BB">$eingabe</span><span style="color: #007700">, </span><span style="color: #0000BB">5</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">);<br /></span><span style="color: #FF8000">// Ergebnis ist array(12, 10, 9, 0, 0)<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">join</span><span style="color: #007700">(</span><span style="color: #DD0000">', '</span><span style="color: #007700">, </span><span style="color: #0000BB">$ergebnis</span><span style="color: #007700">), </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$ergebnis </span><span style="color: #007700">= </span><span style="color: #0000BB">array_pad</span><span style="color: #007700">(</span><span style="color: #0000BB">$eingabe</span><span style="color: #007700">, -</span><span style="color: #0000BB">7</span><span style="color: #007700">, -</span><span style="color: #0000BB">1</span><span style="color: #007700">);<br /></span><span style="color: #FF8000">// Ergebnis ist array(-1, -1, -1, -1, 12, 10, 9)<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">join</span><span style="color: #007700">(</span><span style="color: #DD0000">', '</span><span style="color: #007700">, </span><span style="color: #0000BB">$ergebnis</span><span style="color: #007700">), </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$ergebnis </span><span style="color: #007700">= </span><span style="color: #0000BB">array_pad</span><span style="color: #007700">(</span><span style="color: #0000BB">$eingabe</span><span style="color: #007700">, </span><span style="color: #0000BB">2</span><span style="color: #007700">, </span><span style="color: #DD0000">"noop"</span><span style="color: #007700">);<br /></span><span style="color: #FF8000">// nicht erweitert<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">join</span><span style="color: #007700">(</span><span style="color: #DD0000">', '</span><span style="color: #007700">, </span><span style="color: #0000BB">$ergebnis</span><span style="color: #007700">), </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.array-pad-seealso">
  <h3 class="title">Siehe auch</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.array-fill.php" class="function" rel="rdfs-seeAlso">array_fill()</a> - F&uuml;llt ein Array mit Werten</span></li>
    <li><span class="function"><a href="function.range.php" class="function" rel="rdfs-seeAlso">range()</a> - Erstellt ein Array mit einem Bereich von Elementen</span></li>
   </ul>
  </p>
 </div>


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