note 38657 added to function.current
| From: | mattblissett at hotmail dot com | Date: | Thu, 01 Jan 2004 19:36:19 +0000 |
| Subject: | note 38657 added to function.current | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-62757@lists.php.net to get a copy of this message | ||
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
----
Manual Page -- http://www.php.net/manual/en/function.current.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+38657
Delete -- http://master.php.net/manage/user-notes.php?action=delete+38657&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+38657&report=yes
Search -- http://master.php.net/manage/user-notes.php