cvs: phpdoc /en/reference/array/functions array-map.xml
| From: | Robert Nicholson | Date: | Sun, 20 Jan 2008 14:56:59 +0000 |
| Subject: | cvs: phpdoc /en/reference/array/functions array-map.xml | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-1047@lists.php.net to get a copy of this message | ||
nicholsr Sun Jan 20 14:56:59 2008 UTC
Modified files:
/phpdoc/en/reference/array/functions array-map.xml
Log:
Fixed bug#43612 (array_map behaviour with string keys undocumented)
http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/array/functions/array-map.xml?r1=1.19&r2=1.20&diff_format=u
Index: phpdoc/en/reference/array/functions/array-map.xml
diff -u phpdoc/en/reference/array/functions/array-map.xml:1.19
phpdoc/en/reference/array/functions/array-map.xml:1.20
--- phpdoc/en/reference/array/functions/array-map.xml:1.19 Wed Jun 20 22:24:15 2007
+++ phpdoc/en/reference/array/functions/array-map.xml Sun Jan 20 14:56:59 2008
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.19 $ -->
+<!-- $Revision: 1.20 $ -->
<refentry xmlns="http://docbook.org/ns/docbook"
xml:id="function.array-map">
<refnamediv>
<refname>array_map</refname>
@@ -251,6 +251,68 @@
</screen>
</example>
</para>
+ <para>
+ If the array argument contains string keys then the returned array
+ will contain string keys if and only if exactly one array is passed. If
+ more than one argument is passed then the returned array always has
+ integer keys.
+ </para>
+ <para>
+ <example>
+ <title><function>array_map</function> - with string keys</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$arr = array("stringkey" => "value");
+function cb1($a) {
+ return array ($a);
+}
+function cb2($a, $b) {
+ return array ($a, $b);
+}
+var_dump(array_map("cb1", $arr));
+var_dump(array_map("cb2", $arr, $arr));
+var_dump(array_map(null, $arr));
+var_dump(array_map(null, $arr, $arr));
+?>
+]]>
+ </programlisting>
+ &example.outputs;
+ <screen>
+<![CDATA[
+array(1) {
+ ["stringkey"]=>
+ array(1) {
+ [0]=>
+ string(5) "value"
+ }
+}
+array(1) {
+ [0]=>
+ array(2) {
+ [0]=>
+ string(5) "value"
+ [1]=>
+ string(5) "value"
+ }
+}
+array(1) {
+ ["stringkey"]=>
+ string(5) "value"
+}
+array(1) {
+ [0]=>
+ array(2) {
+ [0]=>
+ string(5) "value"
+ [1]=>
+ string(5) "value"
+ }
+}
+]]>
+ </screen>
+ </example>
+ </para>
</refsect1>
<refsect1 role="seealso">