php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72991 Wrong key in array
Submitted: 2016-09-01 09:25 UTC Modified: 2016-09-01 09:41 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: dimice at dimice dot ru Assigned:
Status: Closed Package: *General Issues
PHP Version: 7.0.10 OS: Windows 10 x64
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: dimice at dimice dot ru
New email:
PHP Version: OS:

 

 [2016-09-01 09:25 UTC] dimice at dimice dot ru
Description:
------------
Sample code:

in PHP 5.5: 
MAX_INT = 2147483647
730022509303030 cast to int => -1671932682, it's OK
730022509303030 key in array => -1671932682, it's OK 

in PHP 7.0:
MAX_INT = 9223372036854775807
730022509303030 cast to int => 730022509303030, it's OK
730022509303030 key in array => -1671932682, WHY!?

See test script.

Test script:
---------------
<?php
	$ar = array();
	$id = (int)730022509303030;
	$ar[$id] = "test";
	var_dump($id);
	var_dump($ar);
?>

Expected result:
----------------
int 730022509303030
array (size=1)
  730022509303030 => string 'test' (length=4)

Actual result:
--------------
int 730022509303030
array (size=1)
  -1671932682 => string 'test' (length=4)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-09-01 09:36 UTC] nikic@php.net
-Status: Open +Status: Feedback
 [2016-09-01 09:36 UTC] nikic@php.net
Please try this with xdebug disabled.
 [2016-09-01 09:41 UTC] dimice at dimice dot ru
Seems works good with xdebug disabled.
 [2016-09-01 09:41 UTC] dimice at dimice dot ru
-Status: Feedback +Status: Closed
 [2016-09-01 09:41 UTC] dimice at dimice dot ru
Issue with xdebug.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 09 13:01:36 2025 UTC