note 12294 deleted from ref.array by sniper

From: Date: Sat, 18 Oct 2003 18:05:45 +0000
Subject: note 12294 deleted from ref.array by sniper
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-58852@lists.php.net to get a copy of this message
Note Submitter: spinn@spinnwebe.com ---- I added this note to array_pop, but it's probably more applicable here: If you use array_pop, the numeric indices will be renumbered if there are any gaps. So if you start with $a[5]="five"; $a[6]="six"; and then do array_pop($a), you now have $a[0]="five", not $a[5]="five", as you might expect. In other words, $a does not necessarily equal array_pop(array_push($a, 1)). Response in the bug database was the following: -- Presently, all splice-derived functions reorder numeric keys. There's not much to do about it, since it's the way Zend Engine handles numeric hash keys. Changing it either way won't bring more consistent functionality, so in the meantime it is just as it is. -- I'd disagree that changing my array indices is consistent, but there you are. I don't know which array functions are splice-derived, so look out for this.

« previous php.notes (#58852) next »