note 55512 deleted from function.current by bjori
| From: | bjori@php.net | Date: | Mon, 24 Apr 2006 15:12:12 +0000 |
| Subject: | note 55512 deleted from function.current by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-109450@lists.php.net to get a copy of this message | ||
Note Submitter: toreriks at hotmail dot com
----
By doing some small changes to the last post, one can make the function seek not just from the start
in a forward manner but also from the end or from a relative position both forwards and backwards.
E.g to seek backwards from a relative position one would supply 'current' as $start, and
'prev' as $iter.
function array_set_current(&$array, $key, $start='reset', $iter='next'){
$start($array);
while (current($array)!==FALSE){
if (key($array) == $key) {
break;
}
$iter($array);
}
return current($array);
}