My solution is:
$maxs = array_keys($array, max($array))
Note:
this way you can retrieve every key related to a given max value.
If you are interested only in one key among all simply use $maxs[0]
More Related Contents:
- In PHP, how do you change the key of an array element?
- php $_POST array empty upon form submission
- How to generate in PHP all combinations of items in multiple arrays
- Find a matching or closest value in an array
- What’s the best way to get the last element of an array without deleting it?
- PHP: Access Array Value on the Fly
- Search for a key in an array, recursively
- Get the first N elements of an array?
- How to use a string as an array index path to retrieve a value?
- PHP Difference between array() and []
- How to get common values from two different arrays in PHP [closed]
- Comment associative array in PHP Documentor
- What is the meaning of [] [closed]
- Unsetting array values in a foreach loop [duplicate]
- PHP – Find parent key of array
- Warning: array_combine(): Both parameters should have an equal number of elements
- Merge multiple associative arrays and add missing columns with a default value
- Find common values in multiple arrays with PHP
- Add elements to array which has gapped numeric keys to form an indexed array / list
- Return only duplicated entries from an array (case-insensitive)
- Returning first x items from array
- Prepend associative array elements to an associative array
- What is the difference between array_udiff_assoc() and array_diff_uassoc()?
- How do I declare a two dimensional array?
- str_replace with array
- How to get array key from corresponding array value?
- How to force Doctrine to update array type fields?
- Combine two 2d arrays and have duplicate rows removed
- How to remove values from two arrays that have the same key and value?
- How to count the consecutive duplicate values in an array?