I have the following code that returns the indexed position of a value which its key matches the provided value in the parameter of the function($haystack).

```
 $results = array("098"=>90,"099"=>89,"100"=>77,"101"=>77);

function getPosition($results,$StudentID){
    arsort($results);

    $index = 1;
    $exists = '';
    $keys = array_keys($results);

    foreach($keys as $key)
    {
        if($key == $StudentID)
        {
        $score = $results[$key];
        $position = $index;
        }
        $index++;
    }
  return $position;

}
echo getPosition($results,"098").'<br />';
echo getPosition($results,"099").'<br />';
echo getPosition($results,"100").'<br />';
echo getPosition($results,"101").'<br />';

```

The results are listed below:

* 90=1
* 89=2
* 77=4
* 77=3

Now my problem is:
1. I don't know how to get the function to return same position for two similar values(eg. 77);

edit: The StudentID parameter in the function is the key for array values.
eg. 098 is a key in the array and its the value for a particular StudentID