PHP Bugs  
php.net | support | documentation | report a bug | advanced search | search howto | statistics | login

go to bug id or search bugs for  

Bug #34419 array_key_exists warns for large numeric keys
Submitted:8 Sep 2005 6:05am UTC Modified: 8 Sep 2005 7:32am UTC
From:bsdson dot tw at yahoo dot com dot tw Assigned to:
Status:Bogus Category:Arrays related
Version:5.0.5 OS:Linux
View/Vote Developer Edit Submission

[8 Sep 2005 6:05am UTC] bsdson dot tw at yahoo dot com dot tw
Description:
------------
The same issue as Bug#21954,
that 'array_key_exists' warns for large numeric keys!

Bug#21954 is believed to be bogus,
but I don't think so!

From the manual of this function, it says that 
"key can be any value possible for an array index".

Since the statement '$a[2163195907] = "hi";' is acceptable for PHP, the
function should accept 2163195907 as the argument 'key', too.

More, PHP is used as a type-less language, why should I bother from
that?!

Reproduce code:
---------------
<?php
	$a = array();
	$a[2163195907] = "hi";
	echo array_key_exists(2163195907,$a);
?>

Expected result:
----------------
true

Actual result:
--------------
Warning: array_key_exists(): The first argument should be either a
string or an integer in bug.php on line 4
[8 Sep 2005 7:32am UTC] sniper@php.net
"This is not a bug, the number you are using is NOT an integer because
it's larger then 2^31-1 (the maximum integer value in PHP) and thus it
will be converted to a float."

This hasn't changed, will not change, and is not a bug.

RSS feed | show source 

PHP Copyright © 2001-2009 The PHP Group
All rights reserved.
Last updated: Sat Nov 21 10:30:49 2009 UTC