<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.5 $ -->
<!-- splitted from ./en/functions/array.xml, last change in rev 1.2 -->
  <refentry id="function.array-slice">
   <refnamediv>
    <refname>array_slice</refname>
    <refpurpose>Extract a slice of the array</refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>array</type><methodname>array_slice</methodname>
      <methodparam><type>array</type><parameter>array</parameter></methodparam>
      <methodparam><type>int</type><parameter>offset</parameter></methodparam>
      <methodparam choice="opt"><type>int</type><parameter>
        length
       </parameter></methodparam>
     </methodsynopsis>
    <para>
     <function>array_slice</function> returns the sequence of elements
     from the array <parameter>array</parameter> as specified by the
     <parameter>offset</parameter> and <parameter>length</parameter>
     parameters.
    </para>
    <para>
     If <parameter>offset</parameter> is positive, the sequence will
     start at that offset in the <parameter>array</parameter>.  If
     <parameter>offset</parameter> is negative, the sequence will
     start that far from the end of the <parameter>array</parameter>.
    </para>
    <para>
     If <parameter>length</parameter> is given and is positive, then
     the sequence will have that many elements in it. If
     <parameter>length</parameter> is given and is negative then the
     sequence will stop that many elements from the end of the
     array. If it is omitted, then the sequence will have everything
     from <parameter>offset</parameter> up until the end of the
     <parameter>array</parameter>.
    </para>
    <para>
     Note that <function>array_slice</function> will ignore array
     keys, and will calculate offsets and lengths based on the 
     actual positions of elements within the array.
    </para>
    <para>
     <example>
      <title><function>array_slice</function> examples</title>
      <programlisting role="php">
<![CDATA[
<?php
$input = array ("a", "b", "c", "d", "e");

$output = array_slice ($input, 2);      // returns "c", "d", and "e"
$output = array_slice ($input, 2, -1);  // returns "c", "d"
$output = array_slice ($input, -2, 1);  // returns "d"
$output = array_slice ($input, 0, 3);   // returns "a", "b", and "c"
?>
]]>
      </programlisting>
     </example>
    </para>
    <para>
     See also <function>array_splice</function>.
    </para>
   </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
-->