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

Add a Patch

Pull Requests

Add a Pull Request

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: Sun May 19 10:01:32 2024 UTC