Expanding on Ram Dane's answer, the key function is an alternative way to get the key of the current index of the array. You can create the following function,
function get_key($array, $index){
$idx=0;
while($idx!=$index && next($array)) $idx++;
if($idx==$index) return key($array);
else return '';
}