I have an array which looks like this:-
$my_array = array();
$my_array[] = array("is_match" => false, "number_of_matches" => 0);
$my_array[] = array("is_match" => true, "number_of_matches" => 2, "id" => 1);
$my_array[] = array("is_match" => false, "number_of_matches" => 5, "id" => 1);
$my_array[] = array("is_match" => false, "number_of_matches" => 3, "id" => 1);
$my_array[] = array("is_match" => false, "number_of_matches" => 1, "id" => 1);
Now i want to get the array with maximum number of matches i.e number_of_matches. Like in this example i want to get below array
array("is_match" => false, "number_of_matches" => 5, "id" => 1);
I know max() function but it returns maximum value in the array but i want to return the array containing the maximum value in number_of_mataches
usortit, pick the last entry or the first (depending on if you sorted is ascending or descending) of the sorted array. Or a simple foreach loop substituting the current 'winner' with another one if its value is higher.