Req #52822 [Opn->Wfx]: Function like current(), but advancing the internal array pointer by one
| From: | aharvey@php.net | Date: | Mon, 13 Sep 2010 07:30:02 +0000 |
| Subject: | Req #52822 [Opn->Wfx]: Function like current(), but advancing the internal array pointer by one | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-154287@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=52822&edit=1
ID: 52822
Updated by: aharvey@php.net
Reported by: daniel dot alvarez at gmx dot de
Summary: Function like current(), but advancing the internal
array pointer by one
-Status: Open
+Status: Wont fix
Type: Feature/Change Request
Package: *General Issues
Operating System: Whatever
PHP Version: 5.3.3
Block user comment: N
New Comment:
This is basically a value-only version of each() with the same problem
that makes current() and next() more or less useless for iterating:
false values can't be distinguished from the end of the array. I don't
really think there's much need for yet another array function for
something that's so easily done in userspace.
Closing won't fix.
Previous Comments:
------------------------------------------------------------------------
[2010-09-13 01:50:37] daniel dot alvarez at gmx dot de
Description:
------------
It would be great to have a function which is just like current, with
the
difference that it advances the array pointer to the next element after
reading
the current value.
When using current() in a loop, you always have to call next().
Including a
function that acts like current() while automatically advancing the
array
pointer would be more elegant.
It can be implemented in PHP userland like this:
function currentPlusOne($array) {
$element = current($array);
next($array);
return $element;
}
A native implementation among current(), next() etc. would be ideal, of
course.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=52822&edit=1