php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34419 array_key_exists warns for large numeric keys
Submitted: 2005-09-08 06:05 UTC Modified: 2005-09-08 07:32 UTC
From: bsdson dot tw at yahoo dot com dot tw Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 5.0.5 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: bsdson dot tw at yahoo dot com dot tw
New email:
PHP Version: OS:

 

 [2005-09-08 06:05 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-09-08 07:32 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.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Fri Feb 21 16:01:27 2020 UTC