PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of David Hernandez   PHP League Fixtures   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example
Class: PHP League Fixtures
Create a schedule of games to be played by teams
Author: By
Last change:
Date: 8 years ago
Size: 1,197 bytes
 

Contents

Class file image Download
<?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++;
}