title: Increment value in array php
body: <p>I am trying to make a function that grabs all the days that have events that are in a database for a certain user. For instance if there were two events on Jan 23, 2013 it would add Jan 23, 2013 to the array. I got it to work so it adds all the days (without adding the same day twice) but now I want to be able to say how many dates are on each day. So on Jan 23, 2013 it would say they have two events in that day. </p>
  
  <p>I hope this makes sense... I have some code for further aid.</p>
  
  <p>PHP Function (grabbing each day that has events) </p>
  
  <pre><code>//gets upcoming days that have events for a user
      public function get_upcoming_days_with_events() {
          $return_array = array();
          $date_in=null;
          $user_id = $this-&gt;session-&gt;userdata('id');
          $query =$this-&gt;db-&gt;select()-&gt;from('events')-&gt;where('user_id', $user_id)-&gt;get();
          foreach ($query-&gt;result_array() as $event =&gt; $row) {
              $date = strtotime($row['date_due']);
              if (sizeof($return_array) != 0) {
                  foreach ($return_array as $date_in_array =&gt; $row) {
                      $d = $row['full_date'];
                      if (date('Y-m-d', $date) == $d) {
                          //date is already in array
                          //increment the number of assignments on this day
                          $row['number_of_assignments'] += 1;
                          $date_in = true;
                      } else{
                          $date_in = false;
                      }
                  }
              }
              if ($date_in == false) {
                  $return_array[] = array(
                      'day' =&gt; date('d', $date),
                      'month' =&gt; date('m', $date),
                      'full_date' =&gt; date('Y-m-d', $date),
                      'number_of_assignments' =&gt; 1
                  );
              }
          }
          return $return_array;
      }
  </code></pre>
  
  <p>So with this I want to be able to increment $return_array['number_of_assignments'] if my function notices that a certain day has more than one event. </p>
  
  <p>Let me know if you need any more info...</p>
  
  <p>Thanks! :)</p>