php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #3995 unset($array[$index]) yields incorrect results
Submitted: 2000-03-31 16:29 UTC Modified: 2001-09-09 09:40 UTC
From: David_Searles at candle dot com Assigned:
Status: Closed Package: Misbehaving function
PHP Version: 3.0.15 OS: Windows NT 4.0 SP 6
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: David_Searles at candle dot com
New email:
PHP Version: OS:

 

 [2000-03-31 16:29 UTC] David_Searles at candle dot com
Using 'unset($array[$index])' yields incorrect results. For example, ...

    $test[0] = "2"
    $test[1] = "1"
    $test["count"] = 2;

This simulates what is returned by several LDAP functions. If you echo this array OR call 'count' on it, all looks fine. Now ...

    unset($test["count"]);

This removes the "count" entry. So far so good. If you echo this array OR call 'count' on it, it still looks fine. Now ...

    sort($test);

This sorts the array but the array is now hosed. The first element appears to be a "null" element and the second element is "1". The "2" element is either no longer addressable in the array OR doesn't exist in the array at all.

It appears that 'unset' doesn't TRULY remove an element from an array but merely marks it as logically deleted. Is this the way it's supposed to work? If so, how can I TRULY delete an array element?

Thanks for a GREAT product!

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-09-09 09:40 UTC] sterling@php.net
fixed in php4
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 02 13:01:30 2024 UTC