title: Creating an array with date information based on two dates
body: <p>I created the following array manually (bottom), I wish to create it programmatically using only two strings which can be easily exploded (explode()).</p>
  
  <pre><code>$min_date = '2012-03-01 00:00:00';
  $max_date = '2012-04-25 00:00:00';
  </code></pre>
  
  <p>I've already explode() the strings as well as found out how many months are between the two dates</p>
  
  <pre><code>    $min_date = explode('-',$min_date);
      $min_date['year'] = intval($min_date[0]);
      $min_date['month'] = intval($min_date[1]);
      $min_date['day'] = intval($min_date[2]);
  
      $max_date = explode('-',$max_date);
      $max_date['year'] = intval($max_date[0]);
      $max_date['month'] = intval($max_date[1]);
      $max_date['day'] = intval($max_date[2]);
  
  $months_between = ($max_date['month'] - $min_date['month']) + 12 * ($max_date['year'] - $min_date['year']);
  </code></pre>
  
  <p>which returns 1</p>
  
  <p><code>cal_days_in_month()</code> function seems useful too, I just don't know how...</p>
  
  <pre><code>$days_in_month = cal_days_in_month(CAL_GREGORIAN, $month, $year)
  </code></pre>
  
  <p>Here is the array I created manually!</p>
  
  <pre><code>$periods = array(
    '0' =&gt; array(
      'month'=&gt;'march',
      'week'=&gt;'1',
      'days'=&gt;'4',
      'readable'=&gt;' Thurs Mar, 01, 2012 - Sun Mar, 04, 2012',
      'created_at_min'=&gt;'2012-03-01 00:00:00',
      'created_at_max'=&gt;'2012-03-04 24:00:00'
    ),
    '1' =&gt; array(
      'month'=&gt;'march',
      'week'=&gt;'2',
      'days'=&gt;'7',
      'readable'=&gt;' Mon Mar, 05, 2012 - Sun Mar, 11, 2012',
      'created_at_min'=&gt;'2012-03-05 00:00:00',
      'created_at_max'=&gt;'2012-03-11 24:00:00'
    ),
    '2' =&gt; array(
      'month'=&gt;'march',
      'week'=&gt;'3',
      'days'=&gt;'7',
      'readable'=&gt;' Mon Mar, 12, 2012 - Sun Mar, 18, 2012',
      'created_at_min'=&gt;'2012-03-12 00:00:00',
      'created_at_max'=&gt;'2012-03-18 24:00:00'
    ),
    '3' =&gt; array(
      'month'=&gt;'march',
      'week'=&gt;'4',
      'days'=&gt;'7',
      'readable'=&gt;' Mon Mar, 19, 2012 - Sun Mar, 25, 2012',
      'created_at_min'=&gt;'2012-03-19 00:00:00',
      'created_at_max'=&gt;'2012-03-25 24:00:00'
    ),
    '4' =&gt; array(
      'month'=&gt;'march',
      'week'=&gt;'5',
      'days'=&gt;'6',
      'readable'=&gt;' Mon Mar, 26, 2012 - Sun Mar, 31, 2012',
      'created_at_min'=&gt;'2012-03-26 00:00:00',
      'created_at_max'=&gt;'2012-03-31 24:00:00'
    ),
    '5' =&gt; array(
      'month'=&gt;'april',
      'week'=&gt;'1',
      'days'=&gt;'1',
      'readable'=&gt;' Sun Apr, 1, 2012',
      'created_at_min'=&gt;'2012-04-01 00:00:00',
      'created_at_max'=&gt;'2012-04-01 24:00:00'
    ),
    '6' =&gt; array(
      'month'=&gt;'april',
      'week'=&gt;'2',
      'days'=&gt;'7',
      'readable'=&gt;' Mon Apr, 2, 2012 - Sun Apr, 8, 2012',
      'created_at_min'=&gt;'2012-04-01 00:00:00',
      'created_at_max'=&gt;'2012-04-08 24:00:00'
    ),
    '7' =&gt; array(
      'month'=&gt;'april',
      'week'=&gt;'3',
      'days'=&gt;'7',
      'readable'=&gt;' Mon Apr, 9, 2012 - Sun Apr, 15, 2012',
      'created_at_min'=&gt;'2012-04-09 00:00:00',
      'created_at_max'=&gt;'2012-04-15 24:00:00'
    ),
    '8' =&gt; array(
      'month'=&gt;'april',
      'week'=&gt;'4',
      'days'=&gt;'7',
      'readable'=&gt;' Mon Apr, 16, 2012 - Sun Apr, 22, 2012',
      'created_at_min'=&gt;'2012-04-16 00:00:00',
      'created_at_max'=&gt;'2012-04-22 24:00:00'
    ),
    '9' =&gt; array(
      'month'=&gt;'april',
      'week'=&gt;'5',
      'days'=&gt;'3',
      'readable'=&gt;' Mon Apr, 23, 2012 - Wed Apr, 25, 2012',
      'created_at_min'=&gt;'2012-04-16 00:00:00',
      'created_at_max'=&gt;'2012-04-25 00:00:00' // note last day timestamp needs to be 00:00:00
    ),
  );
  </code></pre>
  
  <p><strong>Is their anything that PHP offers that can be of extreme help before I dive into this?</strong></p>
  
  <pre><code>$weeks = array(
    'may' = array(1,2,3,4,5),
    'april' = array(1,2,3,4,5),
  );
  </code></pre>