cvs: phpdoc-es /reference/array/functions array-filter.xml
| From: | Robert S�nchez | Date: | Thu, 03 Jul 2003 23:25:40 +0000 |
| Subject: | cvs: phpdoc-es /reference/array/functions array-filter.xml | ||
| Groups: | php.doc.es | ||
| Request: | Send a blank email to doc-es+get-300@lists.php.net to get a copy of this message | ||
reven Thu Jul 3 19:25:40 2003 EDT
Added files:
/phpdoc-es/reference/array/functions array-filter.xml
Log:
primera traduccion
Index: phpdoc-es/reference/array/functions/array-filter.xml
+++ phpdoc-es/reference/array/functions/array-filter.xml
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.1 $ -->
<!-- EN-Revision: 1.11 Maintainer: reven Status: ready -->
<refentry id="function.array-filter">
<refnamediv>
<refname>array_filter</refname>
<refpurpose>
Filtra elementos de una matriz mediante una función "callback"
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>array</type><methodname>array_filter</methodname>
<methodparam><type>array</type><parameter>input</parameter></methodparam>
<methodparam
choice="opt"><type>callback</type><parameter>function</parameter></methodparam>
</methodsynopsis>
<para>
<function>array_filter</function> repasa cada valor en la matriz
<parameter>input</parameter> y lo pasa a la función
<parameter>callback</parameter>. Si la función <parameter>
callback</parameter> devuelve verdadero, el valor es devuelto a la matriz
resultado. Los índices de la matriz se mantienen.
</para>
<para>
<example>
<title>Ejemplo de <function>array_filter</function></title>
<programlisting role="php">
<![CDATA[
<?php
function impar($var) {
return ($var % 2 == 1);
}
function par($var) {
return ($var % 2 == 0);
}
$array1 = array ("a"=>1, "b"=>2, "c"=>3, "d"=>4,
"e"=>5);
$array2 = array (6, 7, 8, 9, 10, 11, 12);
echo "Impares :\n";
print_r(array_filter($array1, "impar"));
echo "Pares:\n";
print_r(array_filter($array2, "par"));
?>
]]>
</programlisting>
<para>
La salida en pantalla del programa anterior será:
</para>
<screen role="php">
<![CDATA[
Impares :
Array
(
[a] => 1
[c] => 3
[e] => 5
)
Pares:
Array
(
[0] => 6
[2] => 8
[4] => 10
[6] => 12
)
]]>
</screen>
</example>
</para>
<para>
No se debe modificar la matriz a la que <function>array_filter</function>
se aplica desde la función "callback", como p. ej. añadir o
eliminar un elemento, o realizar un "unset()". Si la matriz es modificada
el comportamiento de esta función no está definido.
</para>
<para>
Ver también <function>array_map</function>,
<function>array_reduce</function>, y <function>array_walk</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
-->