function getDistancePairOfCour($cour, $pair, $db)
{
    $total = 0;
    $user1 = getPlayerById($pair['user_j1_fk'], $db);
    $user2 = getPlayerById($pair['user_j2_fk'], $db);
    $total += getDistance($cour['court_address'], $user1['address']);
    $total += getDistance($cour['court_address'], $user2['address']);
    return $total;
}
                             foreach ($current_winner_placing as $key => $cur) {
                                 if ($debug) {
                                     echo "<div>{$cur} &rarr; " . getPlayerById($cur)['tag'] . " &rarr; {$placing}</div>";
                                 }
                                 $events[$event_id]['games'][$game_id]['results'][$placing][getPlayerById($cur)['tag']] = getPlayerById($cur);
                             }
                             $placing += count($current_winner_placing);
                             // Add Losers
                             if (!isset($events[$event_id]['games'][$game_id]['results'][$placing])) {
                                 $events[$event_id]['games'][$game_id]['results'][$placing] = [];
                             }
                             foreach ($current_loser_placing as $key => $cur) {
                                 if ($debug) {
                                     echo "<div>{$cur} &rarr; " . getPlayerById($cur)['tag'] . " &rarr; {$placing}</div>";
                                 }
                                 $events[$event_id]['games'][$game_id]['results'][$placing][getPlayerById($cur)['tag']] = getPlayerById($cur);
                             }
                             $placing += count($current_loser_placing);
                             $prev_round = $mi;
                             $current_winner_placing = [];
                             $current_loser_placing = [];
                         }
                     }
                 }
             }
         }
         foreach ($events[$event_id]['games'][$game_id]['results'] as $key => $placing) {
             ksort($events[$event_id]['games'][$game_id]['results'][$key]);
         }
     }
 }