I have associative array like
array
{
[company 1]=>array
(
[1981] => 1
[1945] => 3
)
[company 2]=>array
(
[1990] => 18
[2005] => 13
)
[company 3]=>array
(
[1950] => 6
[2012] => 9
)
}
I want to get lowest and highest key i.e. 1945 and 2012.
How can i achieve this? I have already searched over stackoverflow and Hightest value of an associative array is the nearest possibility but it gives out min and max value and I want min and max key.
**I don’t want to use foreach loop **
If you really hate
foreach, here’s a solution:Your
$arrwould end up like this:Now you can use
min()andmax()functions orsort()it get the highest and lowest value easily.