<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.9 $ -->
<!-- splitted from ./en/functions/array.xml, last change in rev 1.2 -->
  <refentry id="function.array-chunk">
   <refnamediv>
    <refname>array_chunk</refname>
    <refpurpose>Split an array into chunks</refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>array</type><methodname>array_chunk</methodname>
      <methodparam><type>array</type><parameter>input</parameter></methodparam>
      <methodparam><type>int</type><parameter>size</parameter></methodparam>
      <methodparam choice="opt"><type>bool</type><parameter>preserve_keys</parameter></methodparam>
     </methodsynopsis>
    <para>
     <function>array_chunk</function> splits the array into
     several arrays with <parameter>size</parameter> values
     in them. You may also have an array with less values
     at the end. You get the arrays as members of a
     multidimensional array indexed with numbers starting
     from zero.
    </para>
    <para>
     By setting the optional <parameter>preserve_keys</parameter>
     parameter to &true;, you can force PHP to preserve the original
     keys from the input array. If you specify &false; new number
     indices will be used in each resulting array with
     indices starting from zero. The default is &false;.
    </para>
    <example>
     <title><function>array_chunk</function> example</title>
     <programlisting role="php">
<![CDATA[
<?php
$input_array = array('a', 'b', 'c', 'd', 'e');
print_r(array_chunk($input_array, 2));
print_r(array_chunk($input_array, 2, true));
?>
]]>
     </programlisting>
     <para>
      The printout of the above program will be:
     </para>
     <screen>
<![CDATA[
Array
(
    [0] => Array
        (
            [0] => a
            [1] => b
        )

    [1] => Array
        (
            [0] => c
            [1] => d
        )

    [2] => Array
        (
            [0] => e
        )

)
Array
(
    [0] => Array
        (
            [0] => a
            [1] => b
        )

    [1] => Array
        (
            [2] => c
            [3] => d
        )

    [2] => Array
        (
            [4] => e
        )

)
]]>
     </screen>
    </example>
   </refsect1>
  </refentry>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->