php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28404 float array keys equal to zero for isset() and empty()
Submitted: 2004-05-14 20:55 UTC Modified: 2004-05-18 02:05 UTC
From: info at silisoftware dot com Assigned:
Status: Closed Package: Arrays related
PHP Version: 5.0.0RC2 OS: WinXP
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: info at silisoftware dot com
New email:
PHP Version: OS:

 

 [2004-05-14 20:55 UTC] info at silisoftware dot com
Description:
------------
When testing arrays for a key's existance with isset() or empty(), a float key is treated as zero in PHP v5. This behavior differs from PHP v4.3.6.

Reproduce code:
---------------
$MyArray[0] = 'zero';
$key = (float) 5;
$isset = isset($MyArray[$key]);
var_dump($isset);

Expected result:
----------------
bool(false)

Actual result:
--------------
bool(true)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-05-18 02:05 UTC] pollita@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Sep 19 15:01:27 2024 UTC