0
$array = array(
    10 => 6,
    12 => 7,
    13 => 7,
    14 => 4,
    15 => 6);

How to get the list of highest values in the above array? I need index 12 and 13 Any ideas?

Saranya
  • 3
  • 3
  • 1
    "highest" is a superlative degree. How can the index 12 be qualified to be the highest index? – Basit Nov 05 '14 at 10:04
  • PHP has a [built-in function](http://php.net/manual/en/function.max.php) to extract the one element that has the highest value - you'll have to add some of your own logic in order to extract more than one if they are the same value. Why not try to implement this yourself and then come back with some more details if you are still having problems. – Lix Nov 05 '14 at 10:04
  • max($array); return the higher value in that array, but one value :) – Zakaria Wahabi Nov 05 '14 at 10:06
  • $heigher = max($array); $heighVal = array(); foreach ($array as $v) { if ( $v > $heigher || $v == $heigher ) { array_push($heighVal , $v); } } print_r($heighVal); – Zakaria Wahabi Nov 05 '14 at 10:18

1 Answers1

1

you can use following code

$keys = array_keys($array, max($array));
echo "<pre>";
print_r($keys);
echo "</pre>";
Bhumi Shah
  • 9,323
  • 7
  • 63
  • 104