I'm too lazy to consult the PHP manual for a better solution, but here's a quick-n-dirty way:
<?php
// define a function
function find_index($array, $name) {
// set a counter
$i = 0;
// search through the array for the item
while(list($key, $value) = each($array)) {
if($key == $name) {
return $i;
}
$i++;
}
// not found
return false;
}
// let's use it
$rank = find_index($scoreArray, "name1");
echo: "index/rank of name1 is $rank";
?>
remember: the index/rank starts from 0. So you might want to add a 1 (or change the function to start $i from 1)
-sridhar