|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-07-11 17:24 UTC] iliaa@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 04:00:01 2025 UTC |
Description: ------------ The array_combine function skips keys of type other than int or string while operator [] allows one to add also other types (like null,boolean, float). Note, that array_combine converts string keys in exactly the same way as the operator [] does (i.e. "10" -> 10 etc.). IMHO array_combine should not skip keys with other types than string or int but convert them to a string or an int. Thus array_combine should behave like [] operator. Moreover, the PHP_Compat package does it so but there is another bug there: if illegal key is found (e.g. an array) a warning is reported instead of skipping such key (@ is missing there). Reproduce code: --------------- $a = array("0",0,"-10",-10,null,5.4,array(1,2,3),false); $b = array(1,2,3,4,5,6,7,8); var_dump(array_combine($a,$b)); Expected result: ---------------- array(4) { [0]=> int(8) [-10]=> int(4) [""]=> int(5) [5]=> int(6) } Actual result: -------------- array(2) { [0]=> int(2) [-10]=> int(4) }