note 38379 added to function.current

From: Date: Thu, 18 Dec 2003 18:08:14 +0000
Subject: note 38379 added to function.current
Groups: php.notes 
Request: Send a blank email to php-notes+get-62183@lists.php.net to get a copy of this message
Here is a function that sets the current pointer of an array to a given key. Call me crazy but I couldn't find a built in one. This is handy if you want to jump into the middle of an array and then go forward or back using prev() and next(). If someone has a way to do this without traversing I'd love to know what it is. <?php //set the pointer of an array to the given key function array_set_current(&$array, $key){ while(current($array)){ if(key($array) == $key){ break; } next($array); } } ?> Peace, Sam ---- Manual Page -- http://www.php.net/manual/en/function.current.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+38379 Delete -- http://master.php.net/manage/user-notes.php?action=delete+38379&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+38379&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#62183) next »