1
0
mirror of https://github.com/php/doc-it.git synced 2026-03-26 16:42:06 +01:00
Files
archived-doc-it/reference/array/functions/each.xml
Marco Cucinato 63128817e8 sync with EN tree
git-svn-id: https://svn.php.net/repository/phpdoc/it/trunk@115340 c90b9560-bf6c-de11-be94-00142212c4b1
2003-02-09 18:57:09 +00:00

141 lines
4.0 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- splitted from ./it/functions/array.xml, last change in rev 1.1 -->
<!-- last change to 'each' in en/ tree in rev 1.2 -->
<!-- EN-Revision: 1.8 Maintainer: cucinato Status: ready -->
<!-- OLD-Revision: 1.173/EN.1.2 -->
<refentry id="function.each">
<refnamediv>
<refname>each</refname>
<refpurpose>
Restituisce la corrente coppia chiave/valore di un array e incrementa
il puntatore dell'array
</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>array</type><methodname>each</methodname>
<methodparam><type>array</type><parameter>array</parameter></methodparam>
</methodsynopsis>
<para>
Restituisce la corrente coppia chiave/valore corrente di
<parameter>array</parameter> e incrementa il puntatore interno dell'array. Questa
coppia è restituita in un array di quattro elementi, con le chiavi
<emphasis>0</emphasis>, <emphasis>1</emphasis>,
<emphasis>key</emphasis>, and
<emphasis>value</emphasis>. Gli elementi <emphasis>0</emphasis> e
<emphasis>key</emphasis> contengono il nome della chiave dell'elemento
dell'array, mentre <emphasis>1</emphasis> e
<emphasis>value</emphasis> contengono i dati.
</para>
<para>
Se il puntatore interno dell'array punta oltre la fine dei
contenuti dell'array, <function>each</function> restituisce
&false;.
</para>
<para>
<example>
<title>esempi di<function>each</function></title>
<programlisting role="php">
<![CDATA[
$foo = array ("bob", "fred", "jussi", "jouni", "egon", "marliese");
$bar = each ($foo);
print_r($bar);
]]>
</programlisting>
<para>
<varname>$bar</varname> ora contiene la seguente coppia
chiave/valore:
<screen>
<![CDATA[
Array
(
[1] => bob
[value] => bob
[0] => 0
[key] => 0
)
]]>
</screen>
<programlisting role="php">
<![CDATA[
$foo = array ("Robert" => "Bob", "Seppo" => "Sepi");
$bar = each ($foo);ù
print_r($bar);
]]>
</programlisting>
</para>
<para>
<varname>$bar</varname> ora contiene la seguente coppia
chiave/valore:
<screen>
<![CDATA[
Array
(
[1] => Bob
[value] => Bob
[0] => Robert
[key] => Robert
)
]]>
</screen>
</para>
</example>
</para>
<para>
<function>each</function> viene normalmente usata in congiunzione con
<function>list</function> nell'attraversamento di un array; per esempio,
<varname>$_POST</varname>:
<example>
<title>
Attraversamento di <varname>$_POST</varname> con
<function>each</function>
</title>
<programlisting role="php">
<![CDATA[
echo "Valori inviati con il metodo POST:<br />\n";
reset ($_POST);
while (list ($chiave, $valore) = each ($_POST)) {
echo "$chiave => $valore<br />\n";
}
]]>
</programlisting>
</example>
</para>
<para>
Dopo l'esecuzione di <function>each</function>, il puntatore dell'array
viene lasciato sull'elemento successivo, o sull'ultimo
elemento se si è alla fine dell'array. Si deve utilizzare
<function>reset</function> se si vuole riattraversare l'array
usando <function>each</function>.
</para>
<para>
Vedere anche <function>key</function>, <function>list</function>,
<function>current</function>, <function>reset</function>,
<function>next</function>, <function>prev</function> e
<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
-->