mirror of
https://github.com/php/doc-es.git
synced 2026-03-26 16:32:13 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/es/trunk@78203 c90b9560-bf6c-de11-be94-00142212c4b1
119 lines
4.0 KiB
XML
119 lines
4.0 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- splitted from ./es/functions/array.xml, last change in rev 1.1 -->
|
|
<!-- last change to 'each' in en/ tree in rev 1.2 -->
|
|
<refentry id="function.each">
|
|
<refnamediv>
|
|
<refname>each</refname>
|
|
<refpurpose>
|
|
Devuelve el siguiente par clave/valor de una matriz
|
|
</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Descripción</title>
|
|
<methodsynopsis>
|
|
<type>array</type><methodname>each</methodname>
|
|
<methodparam><type>array</type><parameter>matriz</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Devuelve el par clave/valor actual para la
|
|
<parameter>matriz</parameter> y avanza el cursor de la
|
|
misma. Esta pareja se devuele en una matriz de 4 elementos,
|
|
con las claves
|
|
<emphasis>0</emphasis>, <emphasis>1</emphasis>,
|
|
<emphasis>key</emphasis>, y
|
|
<emphasis>value</emphasis>. Los elementos <emphasis>0</emphasis> y
|
|
<emphasis>key</emphasis> contienen el nombre de clave
|
|
del elemento de la matriz, y <emphasis>1</emphasis> y
|
|
<emphasis>value</emphasis> contienen los datos.
|
|
</para>
|
|
<para>
|
|
Si el puntero interno para la matriz apunta pasado el final del
|
|
contenido de la matriz, <function>each</function> devuelve &false;.
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title>Ejemplos de <function>each</function></title>
|
|
<programlisting role="php">
|
|
$chorrada = array ("bob", "fred", "jussi", "jouni", "egon", "marliese");
|
|
$tonteria = each ($chorrada);
|
|
</programlisting>
|
|
<para>
|
|
<literal>$tonteria</literal> contiene ahora los siguientes pares
|
|
clave/valor:
|
|
<itemizedlist spacing="compact">
|
|
<listitem><simpara>0 => 0</simpara></listitem>
|
|
<listitem><simpara>1 => 'bob'</simpara></listitem>
|
|
<listitem><simpara>key => 0</simpara></listitem>
|
|
<listitem><simpara>value => 'bob'</simpara></listitem>
|
|
</itemizedlist>
|
|
|
|
<programlisting role="php">
|
|
$chorrada = array ("Robert" => "Bob", "Seppo" => "Sepi");
|
|
$tonteria = each ($chorrada);
|
|
</programlisting>
|
|
</para>
|
|
<para>
|
|
<literal>$tonteria</literal> contiene ahora los siguientes pares
|
|
clave/valor:
|
|
<itemizedlist spacing="compact">
|
|
<listitem><simpara>0 => 'Robert'</simpara></listitem>
|
|
<listitem><simpara>1 => 'Bob'</simpara></listitem>
|
|
<listitem><simpara>key => 'Robert'</simpara></listitem>
|
|
<listitem><simpara>value => 'Bob'</simpara></listitem>
|
|
</itemizedlist>
|
|
</para>
|
|
</example>
|
|
</para>
|
|
|
|
<para>
|
|
<function>each</function> se usa normalmente de forma conjunta a
|
|
<function>list</function> para recorrer una matriz; por ejemplo,
|
|
$HTTP_POST_VARS:
|
|
<example>
|
|
<title>
|
|
Recorriendo $HTTP_POST_VARS con <function>each</function>
|
|
</title>
|
|
<programlisting role="php">
|
|
echo "Valores enviados con el método POST:<br>";
|
|
reset ($HTTP_POST_VARS);
|
|
while (list ($clave, $val) = each ($HTTP_POST_VARS)) {
|
|
echo "$clave => $val<br>";
|
|
}
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
|
|
<para>
|
|
Cuando se ha ejecutado <function>each</function>, el cursor de la
|
|
matriz quedará en el siguiente elemento de la misma, o en el
|
|
último si llega al final de ésta.
|
|
</para>
|
|
<para>
|
|
Vea también: <function>key</function>, <function>list</function>,
|
|
<function>current</function>, <function>reset</function>,
|
|
<function>next</function>, y <function>prev</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
|
|
-->
|