cvs: phpdoc /en/language/types pseudo-types.xml /en/reference/array/functions array-map.xml
| From: | Kalle Sommer Nielsen | Date: | Fri, 03 Jul 2009 18:21:37 +0000 |
| Subject: | cvs: phpdoc /en/language/types pseudo-types.xml /en/reference/array/functions array-map.xml | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-4323@lists.php.net to get a copy of this message | ||
kalle Fri Jul 3 18:21:37 2009 UTC
Modified files:
/phpdoc/en/language/types pseudo-types.xml
/phpdoc/en/reference/array/functions array-map.xml
Log:
Fixed #48119 (usort() docs don't mention it now takes a lambda)
http://cvs.php.net/viewvc.cgi/phpdoc/en/language/types/pseudo-types.xml?r1=1.3&r2=1.4&diff_format=u
Index: phpdoc/en/language/types/pseudo-types.xml
diff -u phpdoc/en/language/types/pseudo-types.xml:1.3 phpdoc/en/language/types/pseudo-types.xml:1.4
--- phpdoc/en/language/types/pseudo-types.xml:1.3 Thu Feb 21 18:43:17 2008
+++ phpdoc/en/language/types/pseudo-types.xml Fri Jul 3 18:21:37 2009
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<!-- $Revision: 1.3 $ -->
+<!-- $Revision: 1.4 $ -->
<sect1 xml:id="language.pseudo-types">
<title>Pseudo-types and variables used in this documentation</title>
@@ -63,14 +63,16 @@
<para>
Apart from common user-defined function, <function>create_function</function>
- can also be used to create an anonymous callback function.
+ can also be used to create an anonymous callback function. As of PHP 5.3.0
+ its possible to also pass a closure to a callback parameter.
</para>
- <example>
- <title>
- Callback function examples
- </title>
- <programlisting role="php">
+ <para>
+ <example>
+ <title>
+ Callback function examples
+ </title>
+ <programlisting role="php">
<![CDATA[
<?php
@@ -115,8 +117,42 @@
call_user_func(array('B', 'parent::who')); // A
?>
]]>
- </programlisting>
- </example>
+ </programlisting>
+ </example>
+ </para>
+ <para>
+ <example>
+ <title>
+ Callback example using a Closure
+ </title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+// Our closure
+$double = function($a) {
+ return $a * 2;
+};
+
+// This is our range of numbers
+$numbers = range(1, 5);
+
+// Use the closure as a callback here to
+// double the size of each element in our
+// range
+$new_numbers = array_map($double, $numbers);
+
+print implode(' ', $new_numbers);
+?>
+]]>
+ </programlisting>
+ &example.outputs;
+ <screen>
+<![CDATA[
+2 4 6 8 10
+]]>
+ </screen>
+ </example>
+ </para>
<note>
<simpara>
http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/array/functions/array-map.xml?r1=1.22&r2=1.23&diff_format=u
Index: phpdoc/en/reference/array/functions/array-map.xml
diff -u phpdoc/en/reference/array/functions/array-map.xml:1.22
phpdoc/en/reference/array/functions/array-map.xml:1.23
--- phpdoc/en/reference/array/functions/array-map.xml:1.22 Mon Mar 23 21:07:59 2009
+++ phpdoc/en/reference/array/functions/array-map.xml Fri Jul 3 18:21:37 2009
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.22 $ -->
+<!-- $Revision: 1.23 $ -->
<refentry xmlns="http://docbook.org/ns/docbook"
xml:id="function.array-map">
<refnamediv>
<refname>array_map</refname>
@@ -66,31 +66,6 @@
</para>
</refsect1>
- <refsect1 role="changelog">
- &reftitle.changelog;
- <para>
- <informaltable>
- <tgroup cols="2">
- <thead>
- <row>
- <entry>&Version;</entry>
- <entry>&Description;</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry>5.3.0</entry>
- <entry>
- It is now possible to use a lambda function as the
- <parameter>callback</parameter>.
- </entry>
- </row>
- </tbody>
- </tgroup>
- </informaltable>
- </para>
- </refsect1>
-
<refsect1 role="examples">
&reftitle.examples;
<para>
@@ -127,17 +102,15 @@
</screen>
</example>
<example>
- <title><function>array_map</function> using lambda function (as of PHP
5.3.0)</title>
+ <title><function>array_map</function> using a lambda function (as of PHP
5.3.0)</title>
<programlisting role="php">
<![CDATA[
<?php
-
-/* As of PHP 5.3.0 */
-
-$func = function($value) { return $value * 2; };
+$func = function($value) {
+ return $value * 2;
+};
print_r(array_map($func, range(1, 5)));
-
?>
]]>
</programlisting>