#43612 [NEW]: array_map behaviour with string keys undocumented

From: Date: Sun, 16 Dec 2007 23:08:19 +0000
Subject: #43612 [NEW]: array_map behaviour with string keys undocumented
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-355@lists.php.net to get a copy of this message
From: nicholsr@php.net Operating system: all PHP version: Irrelevant PHP Bug Type: Documentation problem Bug description: array_map behaviour with string keys undocumented 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 bug report at http://bugs.php.net/?id=43612&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=43612&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=43612&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=43612&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=43612&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=43612&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=43612&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=43612&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=43612&r=needscript Try newer version: http://bugs.php.net/fix.php?id=43612&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=43612&r=support Expected behavior: http://bugs.php.net/fix.php?id=43612&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=43612&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=43612&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=43612&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=43612&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=43612&r=dst IIS Stability: http://bugs.php.net/fix.php?id=43612&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=43612&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=43612&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=43612&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=43612&r=mysqlcfg

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