Re: array_unique and some questions on Zend hash internals

From: Date: Mon, 05 Jun 2000 13:47:41 +0000
Subject: Re: array_unique and some questions on Zend hash internals
References: 1 2 3  Groups: php.dev 
Request: Send a blank email to php-dev+get-20245@lists.php.net to get a copy of this message
On Sun, 04 Jun 2000, Stig Venaas wrote: > Unless it gets too complicated and slow I will try to preserve keys and > compact indices (similar to array_splice, array_merge...). How would you compact indices? > I think that array_pop, array_shift, array_pad and some of the other > functions could be faster. They use _phpi_splice which copies a lot > of data around. Perhaps I'll look into this later on. Originally, I wrote array_pop and array_shift using zend_hash_del() for removing entries. However, it had side effect in that the indices of the array stayed the same, which did not seem correct, e.g.: $ar = array('a', 'b', 'c'); array_shift($ar); var_dump($ar); array(2) { [1]=> string(1) "a" [2]=> string(1) "b" } And I think it should be: array(2) { [0]=> string(1) "a" [1]=> string(1) "b" } So, it was better to use php_splice() for generalization and so on. -Andrei * Reality isn't all it's cracked up to be. *

« previous php.dev (#20245) next »