-2
Array ( 
    [0] => stdClass Object ( [question_id] => 5 [question_id_count] => 17 ) 
    [1] => stdClass Object ( [question_id] => 8 [question_id_count] => 15 ) 
    [2] => stdClass Object ( [question_id] => 9 [question_id_count] => 17 ) 
    [3] => stdClass Object ( [question_id] => 13 [question_id_count] => 13 ) 
    [4] => stdClass Object ( [question_id] => 14 [question_id_count] => 9 ) 
    [5] => stdClass Object ( [question_id] => 15 [question_id_count] => 13 ) 
    [6] => stdClass Object ( [question_id] => 27 [question_id_count] => 7 ) 
    [7] => stdClass Object ( [question_id] => 28 [question_id_count] => 2 ) 
    [8] => stdClass Object ( [question_id] => 29 [question_id_count] => 8 ) 
)

This is my array, I need the output as: 17 which is the highest value

Ultimater
  • 4,647
  • 2
  • 29
  • 43
deepu np
  • 31
  • 5

3 Answers3

1

try this:

<?php
$test = array("1" => "test", "5" => "bla", "3" => "blubb");

echo max(array_keys($test));
?>

Next solution is:

$maxs = array_keys($array, max($array))

               OR

echo array_search(max($array), $array);
Nimesh Patel
  • 796
  • 1
  • 7
  • 23
0

Use arsort($your_array), and then you will get the first value.

User_1191
  • 981
  • 2
  • 8
  • 24
Haitham Sweilem
  • 1,633
  • 1
  • 12
  • 13
0
$arr = array( 10 => "AAA", 12 => "212", 17 => "SQW" );
max(array_keys($arr));

Output will be: 17

Shahzad Barkati
  • 2,532
  • 6
  • 25
  • 33
Nimatullah Razmjo
  • 1,831
  • 4
  • 22
  • 39
  • Your answer may be good for you. But try to give a brief note on what you've done. This may help someone else. – itsols Dec 14 '15 at 05:36