From:             dharma dot yp at in dot ibm dot com
Operating system: Linux, windows
PHP version:      5.2CVS-2007-11-27 (snap)
PHP Bug Type:     Arrays related
Bug description:  array_combine() doesn't truncate float values while using 
them as keys 

Description:
------------
when array with float values is passed to $keys argument of 
array_combine()function, it creates an array with float keys and the values
specified by $values argument. This is in contradiction with the array
documentation, which specifies that only integers or strings can be used as
keys in an array.Same can be found in the below link.

http://in2.php.net/manual/en/language.types.array.php

So, either of the below is expected:

1) An error message saying that float values can't be used as keys for  an
array should be output or 
2) float keys should be truncated to integer keys.

This behaviour can be found with PHP5.3 and PHP6 as well.


Reproduce code:
---------------
<?php
$arr1 = array(1.1, 2.2);
$arr2 = array(1, 2);
var_dump( array_combine($arr1, $arr2) );
?>


Expected result:
----------------
array(2) {
  [1]=>
  int(1)
  [2]=>
  int(2)
}



Actual result:
--------------
array(2) {
  ["1.1"]=>
  int(1)
  ["2.2"]=>
  int(2)
}


-- 
Edit bug report at http://bugs.php.net/?id=43424&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=43424&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=43424&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=43424&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=43424&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=43424&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=43424&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=43424&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=43424&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=43424&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=43424&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=43424&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=43424&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=43424&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=43424&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=43424&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=43424&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=43424&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=43424&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=43424&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=43424&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=43424&r=mysqlcfg

Reply via email to