mirror of
https://github.com/macintoshplus/doc-fr.git
synced 2026-03-26 09:52:17 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/fr/trunk@114911 c90b9560-bf6c-de11-be94-00142212c4b1
140 lines
3.8 KiB
XML
140 lines
3.8 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 'each' in en/ tree in rev 1.2 -->
|
|
<refentry id="function.each">
|
|
<refnamediv>
|
|
<refname>each</refname>
|
|
<refpurpose>
|
|
Retourne chaque paire clé/valeur d'un tableau
|
|
</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>array</type><methodname>each</methodname>
|
|
<methodparam><type>array</type><parameter>array</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
<function>each</function> retourne la paire clé-valeur courante
|
|
du tableau <parameter>array</parameter> et avance le pointeur de tableau.
|
|
Cette paire est retournée dans un tableau de 4 éléments,
|
|
avec les clés <emphasis>0</emphasis>, <emphasis>1</emphasis>,
|
|
<emphasis>key</emphasis>, et <emphasis>value</emphasis>. Les
|
|
éléments <emphasis>0</emphasis> et <emphasis>key</emphasis>
|
|
contiennent le nom de la clé et, et <emphasis>1</emphasis> et
|
|
<emphasis>value</emphasis> contiennent la valeur.
|
|
</para>
|
|
<para>
|
|
Si le pointeur interne de fichier est au-delà de la fin du tableau,
|
|
<function>each</function> retourne &false;.
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title>Exemples avec <function>each</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$foo = array("ghislain", "damien", "didou", "guillaume", "jim", "christophe");
|
|
$bar = each($foo);
|
|
print_r($bar);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
<para>
|
|
<literal>$bar</literal> contient maintenant les paires suivantes :
|
|
<screen>
|
|
<![CDATA[
|
|
Array
|
|
(
|
|
[1] => ghislain
|
|
[value] => ghislain
|
|
[0] => 0
|
|
[key] => 0
|
|
)
|
|
]]>
|
|
</screen>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$foo = array( "Mehdi" => "Didou","Damien" => "Dams");
|
|
$bar = each($foo);
|
|
print_r($bar);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</para>
|
|
<para>
|
|
<literal>$bar</literal> contient maintenant les paires suivantes :
|
|
<screen>
|
|
<![CDATA[
|
|
Array
|
|
(
|
|
[1] => Didou
|
|
[value] => Didou
|
|
[0] => Mehdi
|
|
[key] => Mehdi
|
|
)
|
|
]]>
|
|
</screen>
|
|
</para>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
<function>each</function> est typiquement utilisé en conjonction
|
|
avec <function>list</function> pour passer en revue un tableau. Par exemple,
|
|
avec <varname>$_POST</varname> :
|
|
<example>
|
|
<title>
|
|
Passer en revue <varname>$_POST</varname> avec
|
|
<function>each</function>
|
|
</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
echo "Valeurs transmises via la méthode POST :<br />\n";
|
|
reset ($_POST);
|
|
while (list ($key, $val) = each ($_POST)) {
|
|
echo "$key => $val<br />\n";
|
|
}
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
Après chaque <function>each</function>, le pointeur de tableau est
|
|
déplacé au prochain élément, ou sur le dernier
|
|
élément, lorsqu'on arrive à la fin.
|
|
</para>
|
|
<para>
|
|
Voir aussi
|
|
<function>key</function>,
|
|
<function>list</function>,
|
|
<function>current</function>,
|
|
<function>reset</function>,
|
|
<function>next</function>,
|
|
<function>prev</function> et
|
|
<link linkend="control-structures.foreach">foreach</link>.
|
|
</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
|
|
-->
|