From: tomas_matousek at hotmail dot com Operating system: WinXP PHP version: 5.0.0RC3 PHP Bug Type: Arrays related Bug description: array_combine skips keys of type other than int or string
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) } -- Edit bug report at http://bugs.php.net/?id=29008&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=29008&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=29008&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=29008&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=29008&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=29008&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=29008&r=needscript Try newer version: http://bugs.php.net/fix.php?id=29008&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=29008&r=support Expected behavior: http://bugs.php.net/fix.php?id=29008&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=29008&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=29008&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=29008&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=29008&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=29008&r=dst IIS Stability: http://bugs.php.net/fix.php?id=29008&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=29008&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=29008&r=float