function.array-fill.html 7.07 KB
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>F&uuml;llt ein Array mit Werten</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.array-fill-keys.html">array_fill_keys</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.array-filter.html">array_filter</a></div>
 <div class="up"><a href="ref.array.html">Array Funktionen</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.array-fill" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">array_fill</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.2.0, PHP 5)</p><p class="refpurpose"><span class="refname">array_fill</span> &mdash; <span class="dc-title">Füllt ein Array mit Werten</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.array-fill-description">
  <h3 class="title">Beschreibung</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">array</span> <span class="methodname"><strong>array_fill</strong></span>
    ( <span class="methodparam"><span class="type">int</span> <code class="parameter">$start_index</code></span>
   , <span class="methodparam"><span class="type">int</span> <code class="parameter">$num</code></span>
   , <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$value</code></span>
   )</div>

  <p class="para rdfs-comment">
   <span class="function"><strong>array_fill()</strong></span> füllt ein Array mit
   <code class="parameter">num</code> Einträgen des Wertes des
   <code class="parameter">value</code> Parameters. Die Indizes des Arrays
   beginnen mit dem <code class="parameter">start_index</code> Parameter.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.array-fill-parameters">
  <h3 class="title">Parameter-Liste</h3>
  <p class="para">
   <dl>


    
     <dt>
<code class="parameter">start_index</code></dt>

     <dd>

      <p class="para">
       Der erste Index des zurückgegebenen Arrays. Nur nicht-negative
       Indizes werden unterstützt.
      </p>
      <p class="para">
       Wenn <code class="parameter">start_index</code> negativ ist, ist der
       erste Index des zurückgebenen Arrays <code class="parameter">start_index</code>;
       alle weiteren Indexe starten bei 0 (siehe
       <a href="function.array-fill.html#function.array-fill.example.basic" class="link">Beispiel</a>).
       </p>
     </dd>

    

    
     <dt>
<code class="parameter">num</code></dt>

     <dd>

      <p class="para">
       Anzahl der einzufügenden Elemente. Muss größer als 0 sein.
      </p>
     </dd>

    

    
     <dt>
<code class="parameter">value</code></dt>

     <dd>

      <p class="para">
       Einzufügender Wert
      </p>
     </dd>

    

   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.array-fill-returnvalues">
  <h3 class="title">Rückgabewerte</h3>
  <p class="para">
   Gibt das gefüllte Array zurück
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-function.array-fill-errors">
  <h3 class="title">Fehler/Exceptions</h3>
  <p class="para">
   Wirft eine <strong><code>E_WARNING</code></strong> wenn
   <code class="parameter">num</code> kleiner als Eins ist.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.array-fill-examples">
  <h3 class="title">Beispiele</h3>
  <p class="para">
   <div class="example" id="function.array-fill.example.basic">
    <p><strong>Beispiel #1 <span class="function"><strong>array_fill()</strong></span>-Beispiel</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$a&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">array_fill</span><span style="color: #007700">(</span><span style="color: #0000BB">5</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">6</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'Banane'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$b&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">array_fill</span><span style="color: #007700">(-</span><span style="color: #0000BB">2</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">4</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'Birne'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$a</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$b</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="cdata"><pre>
Array
(
    [5]  =&gt; Banane
    [6]  =&gt; Banane
    [7]  =&gt; Banane
    [8]  =&gt; Banane
    [9]  =&gt; Banane
    [10] =&gt; Banane
)
Array
(
    [-2] =&gt; Birne
    [0] =&gt; Birne
    [1] =&gt; Birne
    [2] =&gt; Birne
\
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.array-fill-notes">
  <h3 class="title">Anmerkungen</h3>
  <p class="para">
   Beachten Sie auch den <a href="language.types.array.html" class="link">Array</a>-Abschnitt des Handbuchs
   für eine detaillierte Erklärung von negativen Schlüsseln.
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.array-fill-seealso">
  <h3 class="title">Siehe auch</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.array-fill-keys.html" class="function" rel="rdfs-seeAlso">array_fill_keys()</a> - Bef&uuml;llt ein Array mit Werten mit den &uuml;bergebenen Schl&uuml;sseln</span></li>
    <li class="member"><span class="function"><a href="function.str-repeat.html" class="function" rel="rdfs-seeAlso">str_repeat()</a> - Wiederholt einen String</span></li>
    <li class="member"><span class="function"><a href="function.range.html" class="function" rel="rdfs-seeAlso">range()</a> - Erstellt ein Array mit einem Bereich von Elementen</span></li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.array-fill-keys.html">array_fill_keys</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.array-filter.html">array_filter</a></div>
 <div class="up"><a href="ref.array.html">Array Funktionen</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>