Bug #3079: Unset() leaves holes in arrays
| From: | tobias at dnet dot it | Date: | Sat, 01 Jan 2000 16:44:40 +0000 |
| Subject: | Bug #3079: Unset() leaves holes in arrays | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-14187@lists.php.net to get a copy of this message | ||
From: tobias@dnet.it
Operating system: Suse Linux 6.1
PHP version: 3.0.13
PHP Bug Type: Misbehaving function
Bug description: Unset() leaves holes in arrays
Unset(), when applied to array elements, leaves holes in the array.
Take this code:
$array = array("a");
unset($array[0]);
$array[] = "d";
var_dump($array);
This will produce the following output with PHP 3.0.12 and 3.0.13:
array(2) {
int(1)
string(1) "d"
}
a) It would make more sense if the index would be 0.
b) var_dump() sees the array as containing two elements. Count() works fine, though. PHP 4.x's
var_dump() shows correctly array(1).