title: Push sub-array to a specific key in an array
body: <p>I'm sure this is easy to do, I'm just new to this level of PHP programming. Also, please forgive my terminology, I don't know the official names for things, so let me know if something's not clear.</p>
  
  <p>Alright, so I'm building a calendar in PHP, and I've got everything almost working, except I can only display one event per day. I realized this is because I'm storing the event data as sub-keys for a specific key in an array.</p>
  
  <p>Essentially I'm creating each day in the calendar as key in the array. For example:</p>
  
  <pre><code>$events["1"] = "first day of the month";
  $events["2"] = "second day of the month";
  $events["3"] = "third day of the month";
  ...
  </code></pre>
  
  <p>And then inside of each of those, I'm doing something like this:</p>
  
  <pre><code>$events["1"]["title"] = "title for the event on the first day of the month";
  $events["1"]["time"]  = "time for the event on the first day of the month";
  $events["2"]["title"] = "title for the event on the second day of the month";
  $events["2"]["time"]  = "time for the event on the second day of the month";
  ...
  </code></pre>
  
  <p>This setup means I can only store one event per day. If I where to try to set up multiple events, each subsequent event would overwrite the values from the previous.</p>
  
  <p>So what I want to do is set up each event as an array within that key. For example:</p>
  
  <pre><code>$events["1"][0] = array("title" =&gt; "first title for the event on the first day of the month", "time" =&gt; "first time for the event on the first day of the month");
  $events["1"][1] = array("title" =&gt; "second title for the event on the first day of the month", "time" =&gt; "second time for the event on the first day of the month");
  </code></pre>
  
  <p>I could use <code>array_push()</code> to add each event, but I'm not sure how to do that for an array with keys.</p>
  
  <p>Finally, once I have this all stored properly, I need to output each event somehow, so how would I cycle through each sub-array of each day? Right now I'm just doing: </p>
  
  <pre><code>foreach ($events as $event) {
      if ($event["title"] != "") {
          echo "&lt;strong&gt;" . $event["title"] . "&lt;/strong&gt;";
      }
  }
  </code></pre>
  
  <p>I imagine I would need a <code>foreach</code> inside the <code>foreach</code>, but I'm not quite sure how to set that up.</p>
  
  <p>Thanks for the help. Again, I'm sure this is simple to figure out, I'm just not much of a programmer.</p>
  
  <p>PS: This is all being built for a WordPress site, if that makes a difference. I know there's <a href="http://wordpress.stackexchange.com">http://wordpress.stackexchange.com</a>, but I think because this is more general programming questions than anything specific to WordPress that this it the more appropriate site.</p>