I have an array that looks like this:
Array
(
[id] => 12
[team_home_id] => 50
[team_away_id] => 63
[score_team_home] => 1
[score_team_away] => 1
[league_id] => 3
[home_win_pred] => 50
[draw_pred] => 26
[away_win_pred] => 24
)
Nowת I want to look from 3 keys (the 3 predictions: home_win_pred
, draw_pred
, away_win_pred
) which one is the highest and then return that key.
I thought the code I used worked but it seems to return a different key if there is a duplicate value somewhere else in the array. So in the above example it returns team_home_id
because this is also 50 as the highest in my 3.
the code I use:
array_search(max($arr[$x]['home_win_pred'], $arr[$x]['draw_pred'], $arr[$x]['away_win_pred']), $arr[$x]);
for the above example array it returns team_home_id
instead of home_win_pred
How can I fix that?