|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull Requests
Pull requests:
HistoryAllCommentsChangesGit/SVN commits
[2008-01-07 19:48 UTC] bjori@php.net
[2008-01-20 15:04 UTC] nicholsr@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 07 23:00:01 2026 UTC |
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" } }