} } for ($i = count($players); $i > 0; $i--) { for ($j = 1; $j < $i; $j++) { if ($i != $j) { $team[] = $i . ',' . $j; } } } shuffle($team); foreach ($team as $value) { $e = explode(',', $value); shuffle($courts); //echo $e[0].' '; //echo $e[1].'<br>'; Scheduling::RobinLevelMatch($event_id, $tour_id, $e[0], $e[1], $courts[0], $allocate_time, 1, $winner_bracket); } } else { // Order players. for ($i = 0; $i < log($count / 2, 2); $i++) { $out = array(); foreach ($players as $player) { $splice = pow(2, $i); $out = array_merge($out, array_splice($players, 0, $splice)); $out = array_merge($out, array_splice($players, -$splice)); } $players = $out; } $team = array(); $match_per_day = Scheduling::getMatchCount($tour_id); $day_count = Scheduling::getDayGap($tour_id);