PHP Classes

PHP League Fixtures: Create a schedule of games to be played by teams

Recommend this page to a friend!
  Info   View files Example   View files View files (2)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 436 This week: 1All time: 6,275 This week: 571Up
Version License PHP version Categories
fixture 1.0GNU General Publi...5.0Algorithms, PHP 5, Games
Description 

Author

This class can create a schedule of games to be played by teams.

It takes an array with a list of teams and returns another array list of games to be play by the teams on each round.

The class supports lists with a number of teams that may even or odd. In the latter case one team will not play in each round.

Picture of David Hernandez
  Performance   Level  
Name: David Hernandez <contact>
Classes: 1 package by
Country: Mexico Mexico
Age: 37
All time rank: 343741 in Mexico Mexico
Week rank: 420 Up8 in Mexico Mexico Up

Example

<?php
require_once './Fixture.php';
//Example with a pair number of teams
$teams = array("Germany", "England", "France", "Brasil", "Mexico", "Japan", "Nigeria", "Spain");
$fixPair = new Fixture($teams);
$schedule = $fixPair->getSchedule();
//show the rounds
$i = 1;
foreach(
$schedule as $rounds){
    echo
"<h3>Round {$i}</h3>";
    foreach(
$rounds as $game){
        echo
"{$game[0]} vs {$game[1]}<br>";
    }
    echo
"<br>";
   
$i++;
}
echo
"<hr>";


//Example with a odd number of teams
$otherTeams = array("Portugal", "Argentina", "South Korea", "Australia", "Egypt");
$fixOdd = new Fixture($otherTeams);
$games = $fixOdd->getSchedule();
$i = 1;
foreach(
$games as $rounds){
   
$free = "";
    echo
"<h3>Round {$i}</h3>";
    foreach(
$rounds as $match){
        if(
$match[0] == "free this round"){
           
$free = "<span style='color:red;'>{$match[1]} is {$match[0]}</span><br>";
        }elseif(
$match[1] == "free this round"){
           
$free = "<span style='color:red;'>{$match[0]} is {$match[1]}</span><br>";
        }else{
            echo
"{$match[0]} vs {$match[1]}<br>";
        }
    }
    echo
$free;
    echo
"<br>";
   
$i++;
}


  Files folder image Files  
File Role Description
Accessible without login Plain text file example.php Example Example
Plain text file Fixture.php Class Main class

 Version Control Unique User Downloads Download Rankings  
 0%
Total:436
This week:1
All time:6,275
This week:571Up