ID:               45100
 Updated by:       [EMAIL PROTECTED]
 Reported By:      atom at atomsoft dot cz
-Status:           Open
+Status:           Bogus
 Bug Type:         *General Issues
 Operating System: Windows XP
 PHP Version:      5.2.6
 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php




Previous Comments:
------------------------------------------------------------------------

[2008-05-27 15:59:23] [EMAIL PROTECTED]

http://php.net/types.float : "double" is similar to "float"
http://php.net/types.array : "key may only be an integer or string"

Your double/float key will be automatically translated to an int. So
when you do $array[0.1] = 2;, $array[0] will be defined. 

For array_key_exists(), this conversion is not done automatically.
http://php.net/array_key_exists : "key can be any value possible for an
array index" and a float is not a possible value for an array index,
hence the error.

Maybe that conversion should be automatically done in array_key_exists
though.

------------------------------------------------------------------------

[2008-05-27 04:36:01] atom at atomsoft dot cz

Description:
------------
floor() return double type, but in documentation is floor.
This is first bug. But for it exist another bug report.

Second problem is array_key_exists() it hasn't accepted by
array_key_exists, but $a[$key] = 'value' is OK. I think, that PHP accept
double a key index, array_key_exists should be accept it too.

Reproduce code:
---------------
$key = floor(1/10);
$a = array();
$a[$key] = 'value';
echo $a[$key] . "\n";
echo array_key_exists($key, $a)? "YES\n" : "NO\n";
echo gettype($key) . "\n";  

Expected result:
----------------
value
YES
float (according documentation)

Actual result:
--------------
value
Warning:  array_key_exists() function.array-key-exists: The first
argument should be either a string or an integer in ...
NO
double


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=45100&edit=1

Reply via email to