#39541 [Opn]: next_key() and prev_key()
| From: | boots@php.net | Date: | Fri, 17 Nov 2006 03:09:24 +0000 |
| Subject: | #39541 [Opn]: next_key() and prev_key() | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-105131@lists.php.net to get a copy of this message | ||
ID: 39541
User updated by: boots@php.net
Reported By: boots@php.net
Status: Open
Bug Type: Feature/Change Request
Operating System: all
PHP Version: 5.2.0
New Comment:
As a minor request, it would be handy if PHP had analogues for the
prev() and next() functions but which instead returned keys without
affecting the current array pointer.
Presently, one must use prev()/key() next()/key() and these both affect
the array pointer which is inconvenient when looping through an array
with the intention of comparing the current item to its immediate
neighbors.
With next_key() and prev_key() one could get the keys and then directly
lookup the neighboring items without affecting the current position
during looping.
Previous Comments:
------------------------------------------------------------------------
[2006-11-17 02:37:46] boots@php.net
Description:
------------
It would be handy if PHP had functions to get the current and previous
keys in an array without affecting the current array pointer.
Presently, one must use prev()/key() next()/key() and these both affect
the array pointer. This is inconvenient when looping through an array
with the intention of comparing the current item to its immediate
neighbors. Having next_key() and prev_key() would allow one to directly
lookup the neighboring items without affecting the current position
while looping.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=39541&edit=1