note 99883 deleted from function.current by salathe

From: Date: Tue, 14 Dec 2010 11:20:35 +0000
Subject: note 99883 deleted from function.current by salathe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-174901@lists.php.net to get a copy of this message
Note Submitter: Daniel Alvarez Arribas ---- 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 like this: <?php function currentPlusOne($array) { $element = current($array); next($array); return $element; } ?> A native out-of-the-box solution would be ideal, of course.

« previous php.notes (#174901) next »