array_keys
is your friend:
$pets = array(
"cats" => 1,
"dogs" => 2,
"fish" => 3
);
array_keys($pets, min($pets)); # array('cats')
P.S.: there is a dup here somewhere on SO (it had max
instead of min
, but I can distinctly remember it).
More Related Contents:
- PHP – File to Associative Array with 1 key and two values attached
- Finding cartesian product with PHP associative arrays
- In PHP, how do you change the key of an array element?
- Compare 2-dimensional data sets based on a specified second level value
- Convert backslash-delimited string into an associative array
- Is there a way to find out how “deep” a PHP array is?
- Interpolation (double quoted string) of Associative Arrays in PHP
- Replace keys in an array based on another lookup/mapping array
- How to loop through an associative array and get the key? [duplicate]
- Associative array, sum values of the same key
- How to sort a date array in PHP
- Convert an associative array to a simple array of its values in php
- PHP combine two associative arrays into one array
- Display array values in PHP
- Comment associative array in PHP Documentor
- PHP – Merge two arrays (same-length) into one associative?
- Flip associative array and store new values in subarrays to prevent losing duplicated values
- Iterating over a complex Associative Array in PHP
- Generate an associative array from an array of rows using one column as keys and another column as values
- Group rows in an associative array of associative arrays by column value and preserve the original first level keys
- Custom key-sort a flat associative based on another array
- Merge two numerically-keyed associative arrays and preserve the original keys
- PHP/SQL Insert Error when using Named Placeholders
- php: how to get associative array key from numeric index?
- How to use PHP in_array with associative array?
- How does PHP index associative arrays?
- Implementing a simple lookup array
- Filter rows of a 2d array by the rows in another 2d array
- Conditionally add associative element to array
- array_diff to compare two associative arrays