SV: SV: SV: [PHP4BETA] unset() bug or feature?

From: Date: Mon, 03 Jan 2000 22:18:25 +0000
Subject: SV: SV: SV: [PHP4BETA] unset() bug or feature?
References: 1  Groups: php.version4 
Request: Send a blank email to php-version4+get-8871@lists.php.net to get a copy of this message
> >As far as I understand it doesn't reset the internal > >array pointer to $array[0]. If it would, > >the subsequent addition to $array[] would be placed > >in $array[0] and not $array[1] as is the case. > > Ah no. There are really two internal pointers (of different > kinds) inside > a hash. One is a real pointer, that points to the current entry in the > hash (the one that would be returned by the next call to each()). The > other is basically just an incrementing number, that is used to give > automatic indices to array elements that were inserted with implicit keys > (i.e. $foo[] = $bar). This number never decreases. Thanks a lot! - I was beginning to understand this. Do you think it would be a good idea to: either a) Have a function to reset and/or manipulate this "insert pointer"? b) Automatically have this pointer reset when the array has no defined elements? c) Have a function to "compress" an array with only numeric keys, i.e. to remove all key/value pairs that are empty and move everything to the top, starting at index [0]? IMHO, a) is no good, to error/confusion prone, b) I don't know what the implications or overhead would be, maybe just hindering performance of array operations? c) If I knew enough C I would have written it already! (Maybe this is the time to learn, do you think it would be difficult?) Humble regards, /Johan Ekenberg

« previous php.version4 (#8871) next »