mirror of
https://github.com/php/doc-es.git
synced 2026-03-26 00:12:06 +01:00
Aye Caramba Amigos! git-svn-id: https://svn.php.net/repository/phpdoc/es/trunk@133186 c90b9560-bf6c-de11-be94-00142212c4b1
103 lines
3.6 KiB
XML
103 lines
3.6 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 'array-walk' in en/ tree in rev 1.2 -->
|
|
<refentry id="function.array-walk">
|
|
<refnamediv>
|
|
<refname>array_walk</refname>
|
|
<refpurpose>
|
|
Aplica una función del usuario a cada elemento de una matriz.
|
|
</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Descripción</title>
|
|
<methodsynopsis>
|
|
<type>int</type><methodname>array_walk</methodname>
|
|
<methodparam><type>array</type><parameter>matriz</parameter></methodparam>
|
|
<methodparam><type>string</type><parameter>func</parameter></methodparam>
|
|
<methodparam><type>mixed</type><parameter>datosvarios</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<simpara>
|
|
Aplica la función llamada <parameter>func</parameter> a cada elemento de
|
|
la <parameter>matriz</parameter>. La función
|
|
<parameter>func</parameter> recibirá el valor de la matriz como primer
|
|
parámetro y la clave como segundo. Si se proporciona el
|
|
parámetro <parameter>datosvarios</parameter> será pasado como
|
|
tercer parámetro a la función de usuario.
|
|
</simpara>
|
|
<simpara>
|
|
Si <parameter>func</parameter> necesita más de dos o 3 argumentos,
|
|
dependiendo de <parameter>datosvarios</parameter>, se generará un
|
|
aviso cada vez que <function>array_walk</function> llama a
|
|
<parameter>func</parameter>. Estos avisos pueden suprimirse si
|
|
se pone '@' antes de la llamada a <function>array_walk</function>,
|
|
o usando la función <function>error_reporting</function>.
|
|
</simpara>
|
|
<note>
|
|
<para>
|
|
Si <parameter>func</parameter> precisa trabajar con los valores
|
|
reales de la matriz, especifique que el valor del primer parámetro
|
|
de <parameter>func</parameter> debe pasarse por referencia. Desde ese
|
|
instante, los cambios realizados sobre dichos elementos también serán
|
|
realizados en la propia matriz.
|
|
</para>
|
|
</note>
|
|
<note>
|
|
<para>
|
|
El pasar la clave y los datos de usuario a <parameter>func</parameter>
|
|
fue una característica añadida en PHP 4.0.
|
|
</para>
|
|
<para>
|
|
En PHP 4 se debe llamar <function>reset</function> las veces necesarias,
|
|
pues <function>array_walk</function> no reajusta la matriz por
|
|
defecto.
|
|
</para>
|
|
</note>
|
|
<para>
|
|
<example>
|
|
<title>Ejemplo de <function>array_walk</function></title>
|
|
<programlisting role="php">
|
|
$frutas = array ("d"=>"limón", "a"=>"naranja", "b"=>"plátano", "c"=>"manzana");
|
|
|
|
function test_alterar ($item1, $clave, $prefix) {
|
|
$item1 = "$prefix: $item1";
|
|
}
|
|
|
|
function test_ver ($item2, $clave) {
|
|
echo "$clave. $item2<br>\n";
|
|
}
|
|
|
|
array_walk ($frutas, 'test_ver');
|
|
reset ($frutas);
|
|
array_walk ($frutas, 'test_alterar', 'fruta');
|
|
reset ($frutas);
|
|
array_walk ($frutas, 'test_ver');
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<simpara>
|
|
Vea también: <function>each</function> y <function>list</function>.
|
|
</simpara>
|
|
</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
|
|
-->
|