#43612 [Asn->Csd]: array_map behaviour with string keys undocumented

From: Date: Sun, 20 Jan 2008 15:04:49 +0000
Subject: #43612 [Asn->Csd]: array_map behaviour with string keys undocumented
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-457@lists.php.net to get a copy of this message
ID: 43612 Updated by: nicholsr@php.net Reported By: nicholsr@php.net -Status: Assigned +Status: Closed Bug Type: Documentation problem Operating System: all PHP Version: Irrelevant Assigned To: nicholsr New Comment: This bug has been fixed in the documentation's XML sources. Since the online and downloadable versions of the documentation need some time to get updated, we would like to ask you to be a bit patient. Thank you for the report, and for helping us make our documentation better. This bug has been fixed in the documentation's XML sources. Since the online and downloadable versions of the documentation need some time to get updated, we would like to ask you to be a bit patient. Thank you for the report, and for helping us make our documentation better. Previous Comments: ------------------------------------------------------------------------ [2008-01-07 19:48:46] bjori@php.net You have the karma to fix it yourself... :) ------------------------------------------------------------------------ [2007-12-16 23:08:19] nicholsr@php.net Description: ------------ The behaviour of array_map for string keys is not documented. If the array argument contains string keys then the returned array will contain string keys if exactly one array is passed. If more than one argument is passed then the returned array always has integer keys. The following code demonstrates: $ cat 1.php <?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)); ?> 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" } } ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=43612&edit=1

« previous php.doc.bugs (#457) next »