PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy Clear
Copy Format Clear
<?php use Carbon\Carbon; $query = "SELECT VERSION() as version;"; // get DB version using PDO $stmt = $pdo->prepare($query); $stmt->execute(); $row = $stmt->fetch(PDO::FETCH_ASSOC); $tournamentID = 71; $playersCount = 16; $totalRounds = ceil(log($playersCount, 2)); $key = 0; $bracket = array(); $groupID = 1; for($i = 1; $i <= $totalRounds; $i++) { $round = $i; $roundTitle = 'Round ' . $round; $currentRoundPlayers = $playersCount / pow(2, $round - 1); $noOfMatches = $currentRoundPlayers / 2; echo 'Round : ' . $round . ' | Matches : ' . $currentRoundPlayers; $bracket[$key] = array( 'round_title' => $roundTitle, 'round' => $round, ); if($key %2 == 1) { $groupID = $groupID + 1; } //Create Empty Slots For Bracket for($matchNo = 1; $matchNo <= $noOfMatches; $matchNo++) { $bracket[$key]['bracketData'][] = array( 'groupID' => $groupID, 'player_1_ID' => '', "name_1" => '', 'class_1' => '', 'img_src_1' => 'assets/uploads/users/default.jpg', 'score_1' => '', 'player_2_ID' => '', "name_2" => '', 'class_2' => '', 'img_src_2' => 'assets/uploads/users/default.jpg', 'score_2' => '' ); } $key++; } echo "<pre>"; print_r($bracket); echo "</pre>";
Show:  
Copy Clear