note 99883 added to function.current

From: Date: Sun, 12 Sep 2010 23:50:53 +0000
Subject: note 99883 added to function.current
Groups: php.notes 
Request: Send a blank email to php-notes+get-172502@lists.php.net to get a copy of this message
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: function currentPlusOne($array) { $element = current($array); next($array); return $element; } A native out-of-the-box solution would be ideal, of course. ---- Server IP: 85.214.154.209 Probable Submitter: 83.135.46.61 ---- Manual Page -- http://www.php.net/manual/en/function.current.php Edit -- https://master.php.net/note/edit/99883 Del: integrated -- https://master.php.net/note/delete/99883/integrated Del: useless -- https://master.php.net/note/delete/99883/useless Del: bad code -- https://master.php.net/note/delete/99883/bad+code Del: spam -- https://master.php.net/note/delete/99883/spam Del: non-english -- https://master.php.net/note/delete/99883/non-english Del: in docs -- https://master.php.net/note/delete/99883/in+docs Del: other reasons-- https://master.php.net/note/delete/99883 Reject -- https://master.php.net/note/reject/99883 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#172502) next »