note 38657 deleted from function.current by bjori

From: Date: Mon, 24 Apr 2006 15:12:19 +0000
Subject: note 38657 deleted from function.current by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-109452@lists.php.net to get a copy of this message
Note Submitter: mattblissett at hotmail dot com ---- Sam said: "Here is a function that sets the current pointer of an array to a given key." If your array pointer doesn't start at the beginning, this won't work for moving the pointer to a lower one. So, use a reset() first: <?php //set the pointer of an array to the given key function array_set_current(&$array, $key){ reset($array); while(current($array)){ if(key($array) == $key){ break; } next($array); } } ?> HTH, Matt

« previous php.notes (#109452) next »