cvs: phpdoc-pt_BR /reference/array/functions array-filter.xml
| From: | Lucas Rocha | Date: | Wed, 04 Sep 2002 17:23:01 +0000 |
| Subject: | cvs: phpdoc-pt_BR /reference/array/functions array-filter.xml | ||
| Groups: | php.doc.pt-br | ||
| Request: | Send a blank email to doc-pt-br+get-108@lists.php.net to get a copy of this message | ||
lucasr Wed Sep 4 13:23:01 2002 EDT
Modified files:
/phpdoc-pt_BR/reference/array/functions array-filter.xml
Log:
Making this file up-to-date
Index: phpdoc-pt_BR/reference/array/functions/array-filter.xml
diff -u phpdoc-pt_BR/reference/array/functions/array-filter.xml:1.2
phpdoc-pt_BR/reference/array/functions/array-filter.xml:1.3
--- phpdoc-pt_BR/reference/array/functions/array-filter.xml:1.2 Sat Apr 20 02:15:58 2002
+++ phpdoc-pt_BR/reference/array/functions/array-filter.xml Wed Sep 4 13:23:01 2002
@@ -1,16 +1,16 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- EN-Revision: 1.2 Maintainer: lucasr Status: ready -->
+<!-- EN-Revision: 1.4 Maintainer: lucasr Status: ready -->
<!-- splitted from ./pt_BR/functions/array.xml, last change in rev 1.1 -->
<!-- last change to 'array-filter' in en/ tree in rev 1.62 -->
<refentry id="function.array-filter">
<refnamediv>
<refname>array_filter</refname>
<refpurpose>
- Filtra os elementos de um array de acordo com uma função
+ Filtra os elementos de um array utilizando uma função
</refpurpose>
</refnamediv>
<refsect1>
- <title>Descrição</title>
+ <title>Descrição</title>
<methodsynopsis>
<type>array</type><methodname>array_filter</methodname>
<methodparam><type>array</type><parameter>input</parameter></methodparam>
@@ -19,9 +19,9 @@
<para>
<function>array_filter</function> retorna um array contendo
todos os elementos do array <parameter>input</parameter> filtrados
- de acordo com a função aplicada. Se o array
- <parameter>input</parameter> é associativo, então as chaves
- são preservadas.
+ de acordo com uma função aplicada. Se o array
+ <parameter>input</parameter> é associativo, as chaves
+ são preservadas.
</para>
<para>
<example>
@@ -36,23 +36,49 @@
return ($var % 2 == 0);
}
-$array1 = array ("a"=>1, "b"=>2, "c"=>3,
"d"=>4, "e"=>5);
+$array1 = array ("a" => 1, "b" => 2, "c" => 3, "d"
=> 4, "e" => 5);
$array2 = array (6, 7, 8, 9, 10, 11, 12);
-$impar_arr = array_filter($array1, "impar");
-$par_arr = array_filter($array2, "par");
+echo "Impares: \n";
+print_r(array_filter($array1, "impar"));
+echo "Pares: \n";
+print_r(array_filter($array2, "par"));
]]>
</programlisting>
+ <para>
+ A saída deste programa seria:
+ <screen role="php">
+<![CDATA[
+Impares:
+Array
+(
+ [a] => 1
+ [c] => 3
+ [e] => 5
+)
+Pares:
+Array
+(
+ [0] => 6
+ [2] => 8
+ [4] => 10
+ [6] => 12
+)
+]]>
+ </screen>
+ </para>
</example>
</para>
+ ¬e.func-callback;
<para>
- Isso faz com que <varname>$impar_arr</varname> tenha
- <literal>array ("a"=>1, "c"=>3,
"e"=>5);</literal>,
- e <varname>$par_arr</varname> tenha
- <literal>array (6, 8, 10, 12);</literal>,
+ As funções utilizadas por <function>array_filter</function>
+ não devem alterar os valores do array.. Por exemplo, adicionar ou
+ remover um elemento, pode apagar o array o qual está sendo aplicada
+ <function>array_filter</function>. Se este array for alterado,
+ o comportamento desta função se torna imprevisvel.
</para>
<para>
- Veja também <function>array_map</function>,
+ Veja também <function>array_map</function> e
<function>array_reduce</function>.
</para>
</refsect1>