adding an example
correcting the callback parameter name


git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@144208 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Mehdi Achour 2003-11-12 21:06:32 +00:00
parent 4b596c4b74
commit d0fefa8d94

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.12 $ -->
<!-- $Revision: 1.13 $ -->
<!-- splitted from ./en/functions/array.xml, last change in rev 1.62 -->
<refentry id="function.array-filter">
<refnamediv>
@ -13,7 +13,7 @@
<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>
<methodparam choice="opt"><type>callback</type><parameter>callback</parameter></methodparam>
</methodsynopsis>
<para>
<function>array_filter</function> iterates over each value in
@ -77,6 +77,47 @@ Array
<function>array_filter</function> is applied to. If the array
is changed, the behavior of this function is undefined.
</para>
<para>
If the <parameter>callback</parameter> function is not supplied,
<function>array_filter</function> will remove all the entries of
<parameter>input</parameter> that are equal to &false;. See <link
linkend="language.types.boolean.casting">converting to boolean</link>
for more information.
</para>
<para>
<example>
<title><function>array_filter</function> without
<parameter>callback</parameter></title>
<programlisting role="php">
<![CDATA[
<?php
$entry = array(
0 => 'foo',
1 => false,
2 => -1,
3 => null,
4 => ''
);
print_r(array_filter($entry));
?>
]]>
</programlisting>
<para>
This will output :
</para>
<screen>
<![CDATA[
Array
(
[0] => foo
[2] => -1
)
]]>
</screen>
</example>
</para>
<para>
See also <function>array_map</function>,
<function>array_reduce</function>, and <function>array_walk</function>.