#44825 [Opn->Bgs]: array_key_exists() The first argument should be either a string or an integer
by felipe other posts by this author
Apr 24 2008 2:45PM messages near this date
#44825 [Bgs]: array_key_exists() The first argument should be either a string or an integer
|
#44824 [NEW]: parse error from comment string
ID: 44825
Updated by: felipe@[...].net
Reported By: dmitrij at stepanov dot lv
-Status: Open
+Status: Bogus
-Bug Type: Unknown/Other Function
+Bug Type: Arrays related
Operating System: Windows XP
PHP Version: 5.2.5
New Comment:
Negative!
Says the documentation:
"A key may be either an integer or a string... Floats in key are
truncated to integer."
$ php -r '$a[2.3] = "foo"; var_dump($a);'
array(1) {
[2]=>
string(3) "foo"
}
Previous Comments:
------------------------------------------------------------------------
[2008-04-24 21:41:58] dmitrij at stepanov dot lv
Description:
------------
array_key_exists() does not accept float as a key. (The first argument
should be either a string or an integer), however it is possible to use
floats as keys.
Reproduce code:
---------------
$array =array(
3.15 => 20);
var_dump( array_key_exists( 3.15, $array)) ."\n";// ERROR: The first
argument should be either a string or an integer
echo $array[3.15];//OK
Expected result:
----------------
boolean(true)
20
Actual result:
--------------
blahblahblah
20
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=44825&edit=1
Thread:
Dmitrij At Stepanov Dot Lv
Dmitrij At Stepanov Dot Lv
felipe
|