title: PHP Random Team Schedule Generator - Round Robin Scheduler
body: <p>After getting negative feedback from asking this question in a new question... here is my revised question. Yes it is the same project I am working on, but I was unclear that I needed to basically have a Round Robin type of scheduler.</p>
  
  <p>I'm working on a Round Robin Style Hockey League Scheduler, and need some help.</p>
  
  <p>The overall goal is for the end admin user to be able to punch in 3 variables and have it perform a round Robin style schedule until the WEEKS counter has been hit. Below is an example of the amount of teams and the amount of weeks games are played.</p>
  
  <pre><code>$Teams = array('team1','team2','team3','team4','team5','team6','team7','team8');
  $Weeks = 16;
  </code></pre>
  
  <p>The goal is to have it loop 16 times, making 4 games a week, having each team playing 1 time a week. The round robin algorithm should have teams playing different teams each week until all possibles combinations have been made, but not exceeding 16 weeks. In the event that we only have 4 teams or less teams than possible combinations, we would need to have the round robin start over again until the weeks number was hit.</p>
  
  <hr>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I am about 90% into what I needed this script to do... but I am stuck on one thing. I need help with merging a multi-dimensional array.</p>
  
  <p>First are the Tiers. Next are the Weeks (all are week 1). Then are the Games for the team match up.</p>
  
  <pre><code>Array
  (
  [1] =&gt; Array
      (
          [1] =&gt; Array
              (
                  [1] =&gt; Array
                      (
                          [home] =&gt; Whalers
                          [visitor] =&gt; Lumberjacks
                      )
  
                  [2] =&gt; Array
                      (
                          [home] =&gt; Team America
                          [visitor] =&gt; Wolfpack
                      )
  
              )
  
      )
  
  [2] =&gt; Array
      (
          [1] =&gt; Array
              (
                  [1] =&gt; Array
                      (
                          [home] =&gt; Warriors
                          [visitor] =&gt; Litchfield Builders
                      )
  
                  [2] =&gt; Array
                      (
                          [home] =&gt; Icemen
                          [visitor] =&gt; Nighthawks
                      )
  
              )
  
      )
  
  [3] =&gt; Array
      (
          [1] =&gt; Array
              (
                  [1] =&gt; Array
                      (
                          [home] =&gt; The Freeze
                          [visitor] =&gt; Devils Rejects
                      )
  
                  [2] =&gt; Array
                      (
                          [home] =&gt; Cobras
                          [visitor] =&gt; New Haven Raiders
                      )
  
                  [3] =&gt; Array
                      (
                          [home] =&gt; Crusaders
                          [visitor] =&gt; Whalers
                      )
  
                  [4] =&gt; Array
                      (
                          [home] =&gt; Blizzard
                          [visitor] =&gt; CT Redlines
                      )
  
              )
  
      )
  </code></pre>
  
  <p>)</p>
  
  <p>I want the end result to drop the tier and merge all same weeks games together to look like the following:</p>
  
  <pre><code>Array
      (
          [1] =&gt; Array
              (
                  [1] =&gt; Array
                      (
                          [home] =&gt; Whalers
                          [visitor] =&gt; Lumberjacks
                      )
  
                  [2] =&gt; Array
                      (
                          [home] =&gt; Team America
                          [visitor] =&gt; Wolfpack
                      )
  
                  [3] =&gt; Array
                      (
                          [home] =&gt; Warriors
                          [visitor] =&gt; Litchfield Builders
                      )
  
                  [4] =&gt; Array
                      (
                          [home] =&gt; Icemen
                          [visitor] =&gt; Nighthawks
                      )
  
                  [5] =&gt; Array
                      (
                          [home] =&gt; The Freeze
                          [visitor] =&gt; Devils Rejects
                      )
  
                  [6] =&gt; Array
                      (
                          [home] =&gt; Cobras
                          [visitor] =&gt; New Haven Raiders
                      )
  
                  [6] =&gt; Array
                      (
                          [home] =&gt; Crusaders
                          [visitor] =&gt; Whalers
                      )
  
                  [8] =&gt; Array
                      (
                          [home] =&gt; Blizzard
                          [visitor] =&gt; CT Redlines
                      )
  
              )
  
      )
  </code></pre>