Bug #3995 Updated: unset($array[$index]) yields incorrect results

From: Date: Sun, 09 Sep 2001 13:40:54 +0000
Subject: Bug #3995 Updated: unset($array[$index]) yields incorrect results
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-65576@lists.php.net to get a copy of this message
ID: 3995 Updated by: sterling Reported By: David_Searles@candle.com Old Status: Open Status: Closed Bug Type: Misbehaving function Operating System: Windows NT 4.0 SP 6 PHP Version: 3.0.15 New Comment: fixed in php4 Previous Comments: ------------------------------------------------------------------------ [2000-03-31 16:29:06] David_Searles@candle.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! ------------------------------------------------------------------------ Edit this bug report at http://bugs.php.net/?id=3995&edit=1

« previous php.dev (#65576) next »