Files
doc-fr/reference/array/functions/array-slice.xml
Hartmut Holzgraefe b8daeaab85 banana-split
git-svn-id: https://svn.php.net/repository/phpdoc/fr/trunk@78204 c90b9560-bf6c-de11-be94-00142212c4b1
2002-04-15 00:40:38 +00:00

95 lines
3.5 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- splitted from ./fr/functions/array.xml, last change in rev 1.30 -->
<!-- last change to 'array-slice' in en/ tree in rev 1.2 -->
<refentry id="function.array-slice">
<refnamediv>
<refname>array_slice</refname>
<refpurpose>Extrait une portion de tableau </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> retourne une s&eacute;rie d'
&eacute;l&eacute;ment du tableau <parameter>array</parameter> commen&ccedil;ant &agrave;
l'offset <parameter>offset</parameter> et repr&eacute;sentant
<parameter>length</parameter> &eacute;l&eacute;ments.
</para>
<para>
Si <parameter>offset</parameter> est positif, la s&eacute;rie commencera
&agrave; cet offset dans le tableau <parameter>array</parameter>. Si
<parameter>offset</parameter> est n&eacute;gatif, cette s&eacute;rie
commencera &agrave; l'offset <parameter>offset</parameter> mais en
commen&ccedil;ant &agrave; la fin du tableau <parameter>array</parameter>.
</para>
<para>
Si <parameter>length</parameter> est fourni et positif, alors la
s&eacute;rie retourn&eacute;e aura autant d'&eacute;l&eacute;ments.
Si <parameter>length</parameter> est fourni et n&eacute;gatif, alors la
s&eacute;rie contiendra les &eacute;l&eacute;ments depuis l'offset
<parameter>offset</parameter> jusqu'&agrave; <parameter>length</parameter>
&eacute;l&eacute;ments en partant de la fin. Si
<parameter>length</parameter> est omis, la s&eacute;quence lira tous les
&eacute;l&eacute;ments du tableau, depuis l'<parameter>offset</parameter>
pr&eacute;cis&eacute; jusqu'&agrave; la fin du tableau.
</para>
<para>
<example>
<title>Exemple avec <function>array_slice</function></title>
<programlisting role="php">
&lt;?php
$input = array("a", "b", "c", "d", "e");
$output = array_slice($input, 2); // retourne "c", "d", et "e"
// les trois exemples suivants sont &eacute;quivalents
$output = array_slice($input, 2, 2); // retourne "c", "d"
$output = array_slice($input, 2, -1); // retourne "c", "d"
// Equivalent &agrave; :
$offset = 2; $length = -1;
$output = array_slice($input, 2, count($input) - $offset + $length);
// retourne "c", "d"
$output = array_slice($input, -2, 1); // retourne "d"
$output = array_slice($input, 0, 3); // retourne "a", "b", et "c"
?&gt;
</programlisting>
</example>
</para>
<para>
Voir aussi
<function>array_splice</function>.
<note>
<para>
<function>array_slice</function> a &eacute;t&eacute; ajout&eacute;e en PHP 4.0.
</para>
</note>
</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
-->