title: Sum Values in Multidimensional Array
body: <p>I'm experimenting with arrays in PHP and I am setting up a fake environment where a "team's" record is held in arrays.</p>
  
  <pre><code>$t1 = array (
          "basicInfo" =&gt; array (
              "The Sineps",
              "December 25, 2010",
              "lemonpole"
          ),
          "overallRecord" =&gt; array (
              0,
              0,
              0,
              0
          ),
          "overallSeasons" =&gt; array (
              "season1.cs" =&gt; array (0, 0, 0),
              "season2.cs" =&gt; array (0, 0, 0)
          ),
          "matches" =&gt; array (
              "season1.cs" =&gt; array (
                  "week1" =&gt; array ("12", "3", "1"),
                  "week2" =&gt; array ("8", "8" ,"0"),
                  "week3" =&gt; array ("8", "8" ,"0")
              ),
              "season2.cs" =&gt; array (
                  "week1" =&gt; array ("9", "2", "5"),
                  "week2" =&gt; array ("12", "2" ,"2")
              )
          )
  );
  </code></pre>
  
  <p>What I am trying to achieve is to add all the <strong>wins</strong>, <strong>loss</strong>, and <strong>draws</strong>, from each season's week to their respective week. So for example, the sum of all the weeks in <strong>$t1["matches"]["season1.cs"]</strong> will be added to <strong>$t1["overallSeasons"]["season1.cs"]</strong>. The result would leave:</p>
  
  <pre><code>"overallSeasons" =&gt; array (
      "season1.cs" =&gt; array (28, 19, 1),
      "season2.cs" =&gt; array (21, 4, 7)
  ),
  </code></pre>
  
  <p>I tried to work this out on my own for the past hour and all I have gotten is a little more knowledge of <strong>for-loops</strong> and <strong>foreach-loops</strong> :o... so I think I now have the basics down such as using <strong>foreach</strong> loops and so on; however, I am still fairly new to this so bear with me! I can get the loop to point to <strong>$t1["matches"]</strong> key and go through each season but I can't seem to figure out how to add all of the <strong>wins</strong>, <strong>loss</strong>, and <strong>draw</strong>, for each individual week. For now, I'm only looking for answers concerning the overall seasons sum since I can work from there once I figure out how to achieve this. Any help will be much appreciated but please, try and keep it simple for me... or comment the code accordingly please!</p>
  
  <p>Thanks!</p>