note 58985 added to language.types.array
| From: | wbeckler+php dot net at gmail dot com | Date: | Wed, 23 Nov 2005 07:46:47 +0000 |
| Subject: | note 58985 added to language.types.array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-98954@lists.php.net to get a copy of this message | ||
This is in response to comment on pop by Joe Morrison <jdm at powerframe dot com> (08-Nov-2004
01:26).
Unlike perl, arrays remain in order no matter what the key is. This is the case whether the key is a
number or a string. When you pop, the last element is the last element in the array's order,
not the highest keyed item.
I think what you really want is to sort your array by the keys. That is easily done with the ksort()
function. After you do that, pop will behave on integer-keyed arrays just as you would expect.
----
Manual Page -- http://www.php.net/manual/en/language.types.array.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+58985
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+58985&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+58985&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+58985&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+58985&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+58985&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+58985&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+58985&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+58985&report=yes
Search -- http://master.php.net/manage/user-notes.php