<?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-chunk.php',
    1 => 'array_chunk',
    2 => 'Splittet ein Array in Teile auf',
  ),
  'up' => 
  array (
    0 => 'ref.array.php',
    1 => 'Array Funktionen',
  ),
  'prev' => 
  array (
    0 => 'function.array-change-key-case.php',
    1 => 'array_change_key_case',
  ),
  'next' => 
  array (
    0 => 'function.array-column.php',
    1 => 'array_column',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'de',
    'path' => 'reference/array/functions/array-chunk.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.array-chunk" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">array_chunk</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.2.0, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">array_chunk</span> &mdash; <span class="dc-title">Splittet ein Array in Teile auf</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.array-chunk-description">
  <h3 class="title">Beschreibung</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>array_chunk</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.boolean.php" class="type bool">bool</a></span> <code class="parameter">$preserve_keys</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong></span></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_chunk()</strong></span> teilt das Array in Arrays mit
   <code class="parameter">length</code> Elementen auf. Das letzte Array kann weniger
   als <code class="parameter">length</code> Werte enthalten.
  </p>
 </div>


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

    
     <dt><code class="parameter">array</code></dt>
     <dd>
      <p class="para">
       Das Eingabe-Array
      </p>
     </dd>
    

    
     <dt><code class="parameter">length</code></dt>
     <dd>
      <p class="para">
       Die Größe der einzelnen Teile
      </p>
     </dd>
    

    
     <dt><code class="parameter">preserve_keys</code></dt>
     <dd>
      <p class="para">
       Falls auf <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> gesetzt, bleiben die Schlüssel erhalten. Der Standard
       ist <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>, wodurch jeder Teil neue numerische Indizes erhält.
      </p>
     </dd>
    

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


 <div class="refsect1 returnvalues" id="refsect1-function.array-chunk-returnvalues">
  <h3 class="title">Rückgabewerte</h3>
  <p class="para">
   Gibt ein mehrdimensionales Array zurück, das beginnend mit Null
   jeweils <code class="parameter">length</code> Elemente enthält.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-function.array-chunk-errors">
  <h3 class="title">Fehler/Exceptions</h3>
  <p class="para">
   Wenn <code class="parameter">length</code> kleiner ist als <code class="literal">1</code>,
   wird ein <span class="classname"><a href="class.valueerror.php" class="classname">ValueError</a></span> ausgelöst.
  </p>
 </div>


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

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.0.0</td>
      <td>
       Wenn <code class="parameter">length</code> kleiner ist als <code class="literal">1</code>,
       wird nun ein <span class="classname"><a href="class.valueerror.php" class="classname">ValueError</a></span> ausgelöst;
       vorher wurde ein Fehler der Stufe <strong><code><a href="errorfunc.constants.php#constant.e-warning">E_WARNING</a></code></strong>
       ausgelöst, und die Funktion gab <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> zurück.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.array-chunk-examples">
  <h3 class="title">Beispiele</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Beispiel #1 <span class="function"><strong>array_chunk()</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 />$input_array </span><span style="color: #007700">= array(</span><span style="color: #DD0000">'a'</span><span style="color: #007700">, </span><span style="color: #DD0000">'b'</span><span style="color: #007700">, </span><span style="color: #DD0000">'c'</span><span style="color: #007700">, </span><span style="color: #DD0000">'d'</span><span style="color: #007700">, </span><span style="color: #DD0000">'e'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">array_chunk</span><span style="color: #007700">(</span><span style="color: #0000BB">$input_array</span><span style="color: #007700">, </span><span style="color: #0000BB">2</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">array_chunk</span><span style="color: #007700">(</span><span style="color: #0000BB">$input_array</span><span style="color: #007700">, </span><span style="color: #0000BB">2</span><span style="color: #007700">, </span><span style="color: #0000BB">true</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
(
    [0] =&gt; Array
        (
            [0] =&gt; a
            [1] =&gt; b
        )

    [1] =&gt; Array
        (
            [0] =&gt; c
            [1] =&gt; d
        )

    [2] =&gt; Array
        (
            [0] =&gt; e
        )

)
Array
(
    [0] =&gt; Array
        (
            [0] =&gt; a
            [1] =&gt; b
        )

    [1] =&gt; Array
        (
            [2] =&gt; c
            [3] =&gt; d
        )

    [2] =&gt; Array
        (
            [4] =&gt; e
        )

)</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.array-chunk-seealso">
  <h3 class="title">Siehe auch</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.array-slice.php" class="function" rel="rdfs-seeAlso">array_slice()</a> - Extrahiert einen Ausschnitt eines Arrays</span></li>
   </ul>
  </p>
 </div>


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