From ea26f5525b1b6006dca77ab058f03ff429ed180b Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Fri, 22 Apr 2005 22:51:14 +0000 Subject: [PATCH] Added array_set_current() function. --- functions.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/functions.php b/functions.php index 96cceef..939d789 100644 --- a/functions.php +++ b/functions.php @@ -372,6 +372,26 @@ class Functions return $string; } + + /** + * Sets the current array position to be the specified key. This function should be avoided on large arrays. + * + * @param array The array whose counter is to be updated + * @param mixed The key of the element of the array that the counter is to be set to + */ + function array_set_current(&$array, $key) + { + reset($array); + while (current($array) !== false) + { + if (key($array) == $key) + { + break; + } + next($array); + } + return current($array); + } } /*=====================================================================*\ -- 2.43.5