Location: PHPKode > scripts > Cup Scheduler > cup-scheduler/class.cupScheduler.php
<?php
###################################################################################################
#  Cup Scheduler LITE v1.
#  Copyright (c) Martin "duno" Polacik <hide@address.com> 2009. All Rights Reserved.
#
#  Cup Scheduler LITE is free php script writen to generate soccer schadule for league cup.
#  Hope it will be usefull. This script is distributed in GNU GPL licence. 
#  See the GNU General Public License for more details http://www.gnu.org/licenses/.
###################################################################################################
Class CupScheduler 
{
  function generate_schedule($names)
  {
    $fixture = $this->custom_shuffle($names);
    $n_elements = array_chunk($fixture, 2);
    /* 
      if your php knowledge  is better you can change next steps, all is done now .
      Fixtures was allready genereated and stored in array $fixture, and matches are stored in this array 
      
      Array structure:
      
      Array
      (
          [0] => Array 
          // fist match
              (
                  [0] => home team
                  [1] => away team
              )
      
          [1] => Array
          // second match
              (
                  [0] => home team
                  [1] => away team
              )      
            etc      
      )    
     */    
    $start = 0;
    while($start<count($n_elements))
    {
      /*  
      you can use while and put data into db, or just print them      
      $start_one = 0;
      $count_one = count($n_elements[$start]);      
      while($start_one < $count_one)
      {
        echo $n_elements[$start][$start_one]." - ";
        $start_one++;  
      }
      */        
      echo $n_elements[$start][0]." vs ".$n_elements[$start][1]."<br>";   
      $start++;
    }    
  }
  function custom_shuffle($my_array = array()) 
  {
    $copy = array();
    while (count($my_array)) 
    {
      $element = array_rand($my_array);
      $copy[$element] = $my_array[$element];
      unset($my_array[$element]);
    }
    return $copy;
  } 
}
?>
Return current item: Cup Scheduler