note 108139 added to function.array-pop
| From: | sven dot uselesspart at e7o dot de | Date: | Sat, 31 Mar 2012 21:40:45 +0000 |
| Subject: | note 108139 added to function.array-pop | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-186929@lists.php.net to get a copy of this message | ||
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.
----
Server IP: 69.147.83.197
Probable Submitter: 176.52.199.174
----
Manual Page -- http://www.php.net/manual/en/function.array-pop.php
Edit -- https://master.php.net/note/edit/108139
Del: integrated -- https://master.php.net/note/delete/108139/integrated
Del: useless -- https://master.php.net/note/delete/108139/useless
Del: bad code -- https://master.php.net/note/delete/108139/bad+code
Del: spam -- https://master.php.net/note/delete/108139/spam
Del: non-english -- https://master.php.net/note/delete/108139/non-english
Del: in docs -- https://master.php.net/note/delete/108139/in+docs
Del: other reasons-- https://master.php.net/note/delete/108139
Reject -- https://master.php.net/note/reject/108139
Search -- https://master.php.net/manage/user-notes.php