title: How to get start and end date of months of a given range of date in php
body: <p>I am using following codes to display start and end dates of current month.</p>
  
  <pre><code>function firstOfMonth() {
  return date("m/d/Y", strtotime(date('m').'/01/'.date('Y').' 00:00:00'));
  }
  
  function lastOfMonth() {
  return date("m/d/Y", strtotime('-1 second',strtotime('+1 month',strtotime(date('m').'/01/'.date('Y').' 00:00:00'))));
  }
  
  $date_start = firstOfMonth();
  $date_end  = lastOfMonth();
  echo $date_start;
  echo $date_end;
  </code></pre>
  
  <p><strong>Question:</strong> How to get start and end dates of all months in a range of date given</p>
  
  <p>For Eg:</p>
  
  <pre><code>function daterange($startdate,$enddate)
  {
  ...
  ...
  ...
  }
  </code></pre>
  
  <p>Expected result be array of start and end dates of each month between date range of <code>$startdate</code> and <code>$enddate</code>.</p>
  
  <p>Help me how to do this....</p>