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
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: 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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Mon May 06 09:01:30 2024 UTC