I have the following array
Array
(
[0] => Array
(
[title] => Title of company1
[link] => https://companywebsite1.com
[result] => 29.814814815
)
[1] => Array
(
[title] => Title of company2
[link] => https://companywebsite2.com
[result] => 143.723259762
)
[2] => Array
(
[title] => Title of company3
[link] => https://companywebsite3.com
[result] => 212.202797203
)
[3] => Array
(
[title] => Title of company4
[link] => https://companywebsite4.com
[result] => 127.884615385
)
[4] => Array
(
[title] => Title of company5
[link] => https://companywebsite5.com
[result] => 175.911330049
)
)
How can I get the parent key of the company with the highest result value? For example a function that would return key 2 because the maximum value here is 212.20
I tried this but it only returns me the maxium value not the key. How can i get the parent key of the company with the maximum result value?
function maxMarks($array) {
$max=0;
foreach ($array as $Rsult) {
$max=$Rsult['result']>$max ?$Rsult['result']:$max;
}
return $max;
}
echo maxMarks($result);