php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #4908 'unset' inconsistency
Submitted: 2000-06-08 17:49 UTC Modified: 2000-06-09 15:23 UTC
From: thomasjf at seas dot upenn dot edu Assigned:
Status: Closed Package: Misbehaving function
PHP Version: 4.0 Release Candidate 2 OS: WinNT 4.0
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: thomasjf at seas dot upenn dot edu
New email:
PHP Version: OS:

 

 [2000-06-08 17:49 UTC] thomasjf at seas dot upenn dot edu
It seems that the 'unset' function fails to handle empty array keys properly:

<?

$z = array();
unset($key);

echo "Test unset with key = '$key'<br>\n";

$z[$key] = 1;
unset($z[$key]);

while( list($k, $v) = each($z) ){
  echo "$k: $v <br>\n";
}

$z = array();
$key = 9;

echo "Test unset with key = '$key'<br>\n";

$z[$key] = 1;
unset($z[$key]);

while( list($k, $v) = each($z) ){
  echo "$k: $v <br>\n";
}

?>

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-06-09 15:23 UTC] andi at cvs dot php dot net
Fixed in latest CVS.
Thanks for the bug report.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Jul 04 22:01:35 2025 UTC