[prev in list] [next in list] [prev in thread] [next in thread]
List: php-doc-cvs
Subject: [DOC-CVS] =?utf-8?q?svn:_/phpdoc/en/trunk/reference/array/functions/_array-map.xml?=
From: George_Peter_Banyard <girgias () php ! net>
Date: 2019-05-21 16:15:12
Message-ID: svn-girgias-1558455312-347462-9149187 () svn ! php ! net
[Download RAW message or body]
girgias Tue, 21 May 2019 16:15:12 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=347462
Log:
Add a note that NULL can be used as a callback and an additional example showing that \
array-map returns the original array if only one array is provided with a NULL \
callback.
Changed paths:
U phpdoc/en/trunk/reference/array/functions/array-map.xml
Modified: phpdoc/en/trunk/reference/array/functions/array-map.xml
===================================================================
--- phpdoc/en/trunk/reference/array/functions/array-map.xml 2019-05-21 15:45:56 UTC \
(rev 347461)
+++ phpdoc/en/trunk/reference/array/functions/array-map.xml 2019-05-21 16:15:12 UTC \
(rev 347462) @@ -36,6 +36,18 @@
<para>
Callback function to run for each element in each array.
</para>
+ <note>
+ <para>
+ &null; can be passed as a value to <parameter>callback</parameter>
+ to perform a ZIP operation on multiple arrays.
+ <warning>
+ <simpara>
+ If only <parameter>array1</parameter> is provided,
+ <methodname>array_map</methodname> will return the input array.
+ </simpara>
+ </warning>
+ </para>
+ </note>
</listitem>
</varlistentry>
<varlistentry>
@@ -220,7 +232,7 @@
</para>
<para>
<example>
- <title>Creating an array of arrays</title>
+ <title>Performing a ZIP operation of arrays</title>
<programlisting role="php">
<![CDATA[
<?php
@@ -283,8 +295,38 @@
if exactly one array is passed. If more than one array is passed, the
returned array will have sequential integer keys.
</para>
+
<para>
<example>
+ <title>
+ &null; <parameter>callback</parameter> with only
+ <parameter>array1</parameter>
+ </title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$array = [1, 2, 3];
+var_dump(array_map(null, $array));
+?>
+]]>
+ </programlisting>
+ &example.outputs;
+ <screen>
+<![CDATA[
+array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+}
+]]>
+ </screen>
+ </example>
+ </para>
+ <para>
+ <example>
<title><function>array_map</function> - with string keys</title>
<programlisting role="php">
<![CDATA[
--
PHP Documentation Commits Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic