note 108139 deleted from function.array-pop by googleguy

From: Date: Mon, 17 Dec 2012 12:24:06 +0000
Subject: note 108139 deleted from function.array-pop by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-192562@lists.php.net to get a copy of this message
Note Submitter: sven dot uselesspart at e7o dot de ---- If you get an error like "Warning: Cannot add element to the array as the next element is already occupied" you shouldn't use the array_pop-function. You can use the unset-function instead: echo $a[count($a)-1]; // or end($a) unset($a[count($a)-1]); The reason is that array_pop doesn't update the internal structures of the array in the way you're expecting, only unset will work in some special cases with extended using the stack.

« previous php.notes (#192562) next »